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
103

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。