Repository navigation
Conversation
849350c to
31ac172
Compare
|
Encoding and decoding errors are in a follow-up on top of this one: #24367. |
|
Pushed a second commit, dde8430, for a case reported in #10026 (comment): the option checks of the They now throw the same Two new tests ( The other |
WSDL and XML schema errors were raised with soap_errorN(E_ERROR, ...). SoapClient turned the fatal error into a SoapFault and caught the bailout in SOAP_CLIENT_END_CODE(), but zend_bailout() had already called gc_protect(1), so the cycle collector stayed off for the rest of the request (phpGH-10026). The WSDL and schema loaders now throw the SoapFault with soap_throw_error() and return an error to their callers, which release what they own on the way out. The message and the fault code ("WSDL") are the same as before. SoapServer and SoapClient with the "exceptions" option disabled keep reporting these errors as fatal errors: the constructor turns the SoapFault back into the same E_ERROR once the loader has cleaned up. Since nothing bails out of the loaders any more, the error paths that existed only to survive a bailout are gone: the zend_try in load_wsdl_ex(), requestify_string() and the copies of targetNamespace in schema_load_file(). delete_type() now also frees an unresolved "ref", which an error before schema_pass2() can leave behind. Errors from encoding and decoding values still bail out and are not covered by this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SoapClient constructor reported a missing "uri" or "location" option in non-WSDL mode and an invalid "encoding" option with php_error_docref(E_ERROR, ...). As with WSDL errors, SoapClient turned the fatal error into a SoapFault and caught the bailout in SOAP_CLIENT_END_CODE(), with gc_protect(1) already set, so the cycle collector stayed off for the rest of the request (phpGH-10026). Reported in php#10026 (comment). These four errors now go through soap_client_option_error(), which throws the same SoapFault ("SoapClient::__construct(): <message>", fault code "Client", also stored in __soap_fault), and the constructor returns. With the "exceptions" option disabled it is the same fatal error as before. The option is read after "uri" and "location" are checked, so as before those two errors are a SoapFault even then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dde8430 to
fda4ac7
Compare
This is the direction suggested in the review of #24338: instead of a special bailout, the WSDL and XML schema loaders of ext/soap now report errors by throwing the
SoapFaultand returning, soSoapClientno longer goes throughzend_bailout()for them. That is the case reported in #10026: a broken WSDL leftgc_status()['protected']attruefor the rest of the request.What changes
soap_throw_error()throws the sameSoapFaultthat the error handler used to build fromsoap_errorN(E_ERROR, ...): sameSOAP-ERROR: ...message, same fault code (WSDL).soap_errorN()calls inphp_sdl.candphp_schema.cuse it now, and every function on the way up returns an error instead of relying on the bailout. Objects that are not yet owned by thesdlare freed where the error happens; everything else is freed bydelete_sdl().is_wsdl_element()returns-1after throwing for an unknown required extension, so callers can tell that apart from "not a WSDL element".SoapServerandSoapClientwithexceptions => falsekeep the current behaviour: after the loader has cleaned up, the constructor turns theSoapFaultback into the sameE_ERROR(soap_fault_to_error()), so the server still answers with a SOAP fault and the client still dies with the same fatal error.SoapClientconstructor ('uri' option is required in nonWSDL mode,'location' option is required in nonWSDL mode,'location' and 'uri' options are required in nonWSDL mode,Invalid 'encoding' option), which werephp_error_docref(E_ERROR, ...)and leftprotectedattruein the same way, with no WSDL involved (reported in Garbage collection stops after exception in SoapClient #10026 (comment)).soap_client_option_error()throws the sameSoapFault(SoapClient::__construct(): <message>, fault codeClient, also stored in__soap_fault) and the constructor returns; withexceptions => falseit is the same fatal error as before.zend_tryaround WSDL imports inload_wsdl_ex(),requestify_string()and thetargetNamespacecopies inschema_load_file().delete_type()now frees an unresolvedref, which an error beforeschema_pass2()can leave behind.The diff of
load_wsdl()is mostly re-indentation after removing itszend_try; it reads better with whitespace changes hidden (?w=1).Encoding and decoding errors in
php_encoding.cstill bail out, so #10026 is not fully fixed by this PR alone: an encoding error in a call (for exampleSOAP-ERROR: Encoding: object has no 'x' property) still leavesprotectedattrue. I would do that in a follow-up in the same way, unless you prefer it in this PR.Testing
Debug build of master (
0b4a5a84492), unless noted otherwise. After rebasing ontode7ff46337f(no changes inext/soapin between),ext/soapwas run again: all tests pass. Rebased again onto2c2a03148e1(13.11.2026), which broughtkeep_headers, the OOM changes and other fixes inext/soap; the conflicts were mechanical (a singlezend_hash_get_current_key()call inschema_attributegroup_fixup(),keep_headersinload_wsdl(), NEWS), andext/soappasses: 552 tests, 0 fail.ext/soap: all tests pass.bugs/gh10026.phpt, andwsdl_errors_no_bailout.phpt, which goes through 48 broken WSDL/schema files, one per error path with its own cleanup. On a debug build any leak on those paths fails the test. Both tests fail on unpatched master, and only on the lines that check the GC state; the messages are the same.de7ff46337f) in Docker: two new tests,soapclient_option_errors_no_bailout.phpt(the four errors, a subclass,exceptions => falseset after theuricheck,__soap_fault, then 20000 cycles are collected) andsoapclient_option_errors_fatal.phpt(exceptions => false: still a fatal error). On unpatched master the first one fails only on the lines that check the GC state, the messages are the same; the second one passes on both.ext/soap: 512 tests pass, 0 fail. Release build with ASAN and UBSAN (with ext/soap: report encoding errors without a bailout #24367 on top),run-tests --asan ext/soap: both new tests pass; only tests that also fail on master fail, with LeakSanitizer reports.SoapClientwith exceptions,SoapClientwithexceptions => false, andSoapServer:SoapFaultmessage and fault code are identical in all 218 cases;protectedistrueafter 216 of them on unpatched master and after none of them with the patch; no leaks, no assertions;exceptions => falseandSoapServer: output is byte-for-byte identical before and after (216 fatal errors / SOAP faults, 2 valid WSDLs);Couldn't load from '%s'without a libxml error,Missing 'name' attribute for <binding>(a binding without a name is rejected earlier, inload_wsdl_ex()), and the secondunexpected <%s> in union(after a loop that only ends withtrav == NULL).USE_ZEND_ALLOC=0: the 218-file corpus in all three modes gives no ASAN or UBSAN report (leak detection off, since the fatal-error modes end the request without freeing; leaks are covered by the debug build above).run-tests --asanonext/soap: both new tests pass; 6 other tests fail with LeakSanitizer reports (bug37013,bug55323,gh16318,gh22585,r3_groupE_list_005w,r3_groupE_list_006w), and they fail the same way without this patch.🤖 Generated with Claude Code