[php-src] Issue #25307: NULL ps_files dereference in ps_files_close at shutdown (SessionHandler + save_handler ini change)
| From: | YuanchengJiang | Date: | Sun, 08 Nov 2026 14:02:00 +0000 |
| Subject: | [php-src] Issue #25307: NULL ps_files dereference in ps_files_close at shutdown (SessionHandler + save_handler ini change) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-254075@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/25307
Author: YuanchengJiang
### Description
The following code:
```php
<?php
session_set_save_handler(new SessionHandler(), true);
ini_set("session.save_handler", "files");
session_start();
(new SessionHandler)->open("", "");
```
Resulted in this output:
```
ext/session/mod_files.c:138:12: runtime error: member access within null pointer of type
'ps_files'
#0 0x3d9adf2 in ps_files_close ext/session/mod_files.c:138:12
#1 0x3d98a34 in ps_close_files ext/session/mod_files.c:457:2
#2 0x3cf3173 in php_rshutdown_session_globals ext/session/session.c:173:4
#3 0x3d6a87f in zm_deactivate_session ext/session/session.c:2967:2
#4 0x5c33176 in zend_deactivate_modules Zend/zend_API.c:3489:5
#5 0x54fd4f0 in php_request_shutdown main/main.c:1986:3
#6 0x6bafcd4 in do_cli sapi/cli/php_cli.c:1160:3
#7 0x6ba61e7 in do_php_cli sapi/cli/php_cli.c:1360:18
#8 0x6ba4851 in main sapi/cli/php_cli_main.c:18:9
#9 0x7f3b428b2d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#10 0x7f3b428b2e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#11 0x606504 in _start (sapi/cli/php+0x606504)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ext/session/mod_files.c:138:12 in
```
To reproduce:
./sapi/cli/php test.php
Commit:
```
33a61f765a94e018a8d55d962a73e8c8331ee256
```
Configurations:
```
CC="clang-12" CXX="clang++-12" CFLAGS="-DZEND_VERIFY_TYPE_INFERENCE"
CXXFLAGS="-DZEND_VERIFY_TYPE_INFERENCE" ./configure --enable-debug
--enable-address-sanitizer --enable-undefined-sanitizer --enable-re2c-cgoto --enable-zts
--enable-bcmath --enable-calendar --enable-dba --enable-dl-test --enable-exif --enable-ftp
--enable-gd --enable-gd-jis-conv --enable-mbstring --enable-pcntl --enable-shmop --enable-soap
--enable-sockets --enable-sysvmsg --enable-zend-test --with-zlib --with-bz2 --with-curl
--with-enchant --with-gettext --with-gmp --with-mhash --with-ldap --with-libedit --with-readline
--with-snmp --with-sodium --with-xsl --with-zip --with-mysqli --with-pdo-mysql --with-pdo-pgsql
--with-pgsql --with-sqlite3 --with-pdo-sqlite --with-webp --with-jpeg --with-freetype
--enable-sigchild --with-pcre-jit --with-iconv
```
Operating System:
```
Ubuntu 20.04 Host, Docker 0599jiangyc/flowfusion:latest
```
*This report is automatically generated by [FlowFusion](https://github.com/php/flowfusion)*
### PHP Version
```plain
nightly
```
### Operating System
_No response_