Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

pdo_sqlite segmentation fault

未關閉
#23,756 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
php, sqlite
領域
databases

研究方向

從 issue 中的重現程式開始,檢查 ext/pdo_sqlite/sqlite_statement.c:54,然後在 collation callback 關閉游標時,追蹤經過 ext/pdo/pdo_stmt.c:456 的呼叫。完成的標準是:提供的腳本在 AddressSanitizer 下不再發生 segfault,且該行為由適當的回歸測試涵蓋。

由索引模型根據 Issue 內容生成。

描述

Bug Status: Needs Triage
Description

The following code:

<?php
$db = Pdo\Sqlite::connect('sqlite::memory:');
$db->exec("CREATE TABLE t(x TEXT)");
$db->exec("INSERT INTO t VALUES ('b'),('a'),('c'),('d'),('e')");

$stmt = null;
$db->createCollation('evil', function ($a, $b) use (&$stmt) {
    $stmt->closeCursor();        
    return $a <=> $b;
});

$stmt = $db->prepare("SELECT x FROM t ORDER BY x COLLATE evil");
$stmt->execute();            

Resulted in this output:


Deprecated: Method PDO::sqliteCreateCollation() is deprecated since 8.5, use Pdo\Sqlite::createCollation() instead in /audit/repro/battery7/e7_06_collation_closecursor.php on line 8
AddressSanitizer:DEADLYSIGNAL
=================================================================
==7==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000000000 bp 0xffffe64c9040 sp 0xffffe64c9020 T0)
==7==Hint: pc points to the zero page.
==7==The signal is caused by a READ memory access.
==7==Hint: address points to the zero page.
    #0 0x0  (<unknown module>)
LLVMSymbolizer: error reading file: No such file or directory
    #1 0xffffade2578c  (linux-vdso.so.1+0x78c)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (<unknown module>) 
==7==ABORTING

gdb backtrace:

#0  0x0000000000000000 in ?? ()
#1  0x... in ?? () from /lib/.../libsqlite3.so.0
#2  0x... in ?? () from /lib/.../libsqlite3.so.0
#3  sqlite3VdbeExec () from libsqlite3.so.0
#4  sqlite3_step () from libsqlite3.so.0
#5  pdo_sqlite_stmt_execute (stmt=...) at ext/pdo_sqlite/sqlite_statement.c:54
#6  zim_PDOStatement_execute (...) at ext/pdo/pdo_stmt.c:456
...
PHP Version
8.6.0-dev
Operating System

Ubuntu 22.04

主要語言
C
星號
40.4k
分支
8.2k
平均合併
2 天 15 小時
30 天內合併 PR
113

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。