[php-src] PR #24368: Fix SoapClient writing to output headers after an exception

From: Date: Fri, 16 Oct 2026 01:36:06 +0000
Subject: [php-src] PR #24368: Fix SoapClient writing to output headers after an exception
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-39495@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/24368 Author: likemusic When decoding a response header throws an exception, for example from a typemap from_xml callback, parse_packet_soap() goes on decoding the remaining headers and adds them to the output headers array (the 5th argument of __soapCall()). The trace of the exception holds a copy of that argument, so the array is shared at that point: - a debug build fails with _zend_hash_str_add_or_update_i: Assertion '(zend_gc_refcount(&(ht)->gc) == 1) || ((ht)->u.flags & (1<<6))' failed; - a release build changes the array that the trace shows: with headers h1, h2 (whose callback throws) and h3, $e->getTrace()[1]['args'][4] contains all three instead of ['h1' => 1], which was the value when the exception was thrown. This stops decoding the headers once an exception is pending. The headers decoded before it stay in the output array, as the test shows. I found it while testing #24367, which stops decoding headers after an encoding error for the same reason. The loop is unchanged since PHP 7 (c446e575880), and master has the same problem. Merging up into master conflicts in one line (master casts trav->name to const char* in the add_assoc_zval() call). Testing, debug build of PHP-8.4 (25348e809d4): - the new test output_headers_exception.phpt passes; without the fix it fails with the assertion above, and on a release build (ASAN) without the fix it fails on the arrays, which contain h2 => NULL and h3 => 3; - ext/soap: all tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)

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