[php-src] PR #25942: ext/dba: Do not close shared persistent stream in dba_close_info()
| From: | hohphu8 | Date: | Mon, 30 Nov 2026 11:44:25 +0000 |
| Subject: | [php-src] PR #25942: ext/dba: Do not close shared persistent stream in dba_close_info() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41244@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25942
Author: hohphu8
When a second
dba_popen() call opens the same underlying persistent
php_stream as an existing live persistent DBA connection and then fails during driver
initialization (for example, opening an existing flatfile database with
cdb), the fail: path in php_dba_open() calls
dba_close_info(), which unconditionally calls php_stream_pclose() on
info->fp and info->lock.fp. This closes the persistent stream still
owned by the live connection, causing a use-after-free / SIGSEGV on the next DBA operation.
This extracts a per-stream dba_stream_is_shared() helper (reused by
dba_info_shares_stream()) and skips php_stream_pclose() in
dba_close_info() when another persistent dba_info in
EG(persistent_list) still references that stream.
Adds ext/dba/tests/dba_popen_failed_second_open_shared_stream.phpt. Verified crash
(SIGSEGV) -> PASS on PHP-8.4 (Debug + ZTS), with ext/dba/tests/ passing
39/39.
Note: AI-assisted code audit; manually verified and reproduced locally.