[php-src] Issue #23756: pdo_sqlite segmentation fault
| From: | djarfluka | Date: | Fri, 18 Sep 2026 15:57:51 +0000 |
| Subject: | [php-src] Issue #23756: pdo_sqlite segmentation fault | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252773@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/23756
Author: djarfluka
### Description
The following code:
```php
<?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
```plain
8.6.0-dev
```
### Operating System
Ubuntu 22.04