[php-src] PR #26000: Fix GH-25677: Use-after-free when a destructor calls error_get_last() while the fatal error backtrace is released

From: Date: Tue, 01 Dec 2026 19:03:44 +0000
Subject: [php-src] PR #26000: Fix GH-25677: Use-after-free when a destructor calls error_get_last() while the fatal error backtrace is released
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41331@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/26000 Author: Harp404 Fixes GH-25677. > zend_error_zstr_at() released > EG(last_fatal_error_backtrace) before unsetting it. When the > backtrace's frame args hold the last reference to an object, its destructor runs during that > release, and error_get_last() called from the destructor copies the > array that is being destroyed. The fix moves the backtrace to a local zval and unsets the global > first, so error_get_last() no longer returns a > trace key there. > > Zend/tests/backtrace/gh25677.phpt is the reproducer from the > issue. Without the fix it fails, and the issue's script reports a heap-use-after-free with an > ASan build (USE_ZEND_ALLOC=0). With the fix it passes, as do > Zend/tests/backtrace, > Zend/tests/gh*.phpt and > error_get_last_002.phpt under > --asan. Targets PHP-8.5, where fatal error backtraces were added. I used Claude Code (Opus 5.5) to help investigate and draft this change; the quoted text above was written with it. I reproduced the bug and checked the fix myself.

« previous php.git-pulls (#41331) next »