-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #79191: Error in SoapClient ctor disables DOMDocument::save() #5133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The culprit is the too restrictive fix for bug #71536, which prevents `php_libxml_streams_IO_write()` from properly executing when unclean shutdown is flagged. However, the fix for bug #79029 already prevents that call during shutdown in the first place, so that it actually fixes bug #71536 as well. Thus, we can just revert the original fix for bug #71536. Thanks to bwoebi and daverandom for helping to investigate this issue.
Ah, almost forgot: there may be an additional fix needed regarding the context switch: Lines 3302 to 3319 in 494615f
If load_wsd() throws (like in this case), we may have to catch that, and restore the context.
|
Can you please link the relevant commits? |
Bug #71536 has been fixed with commit 93592a9. |
The Travis segfault happens only for PHP 7.3, since the |
To clarify: this PR is fine for PHP-7.4+, but not for PHP-7.3 where it would cause segfaults. Leaving PHP-7.3 as is, would not only mean that bug #79191 would not be fixed there, but also that variants of bug #71536 (which do not rely on unclean shutdown, but rather on late destruction of XMLWriters) would still segfault. |
The current test for index 2e76a4e409..b6b0c84b18 100644
--- a/ext/xmlwriter/tests/bug79029.phpt
+++ b/ext/xmlwriter/tests/bug79029.phpt
@@ -11,13 +11,13 @@ $x = array( new XMLWriter() );
$x[0]->openUri("bug79029_1.txt");
$x[0]->startComment();
-$x = new XMLWriter();
-$x->openUri("bug79029_2.txt");
+$y = new XMLWriter();
+$y->openUri("bug79029_2.txt");
fclose(@end(get_resources()));
file_put_contents("bug79029_3.txt", "a");
-$x = new XMLReader();
-$x->open("bug79029_3.txt");
+$z = new XMLReader();
+$z->open("bug79029_3.txt");
fclose(@end(get_resources()));
?>
okey |
After looking into this a bit, I think the proper fix (for master) for various stream resource destruction issues we've been seeing is to make resource destruction a two phase process. First we destroy all non-stream resources and run object dtors, and then we destroy all stream resources that are still live. For the purposes of this PR, it should be fine if you move the |
The variables must not be overwritten, because otherwise these parts won't trigger the issue which happened during shutdown.
I've made the suggested changes.
Sounds like a sensible improvement. |
After thinking about this a bit more, I think this is on the wrong track... Instead, we should move the xmlwriter_free_resource_ptr call into dtor_obj, rather than free_obj, so it runs prior to resource destruction. |
I've though about that as well, but AIUI |
@cmb69 Well, the current implementation always leaks if the XmlWriter is destroyed during shutdown, because the |
We're moving the `xmlwriter_free_resource_ptr()` call from the `free_obj` handler to an added `dtor_obj` handler, to avoid to write to a closed stream in case of late object freeing. Since some of the earlier changes are no longer needed now, we revert them.
@nikic, ah, of course! I've done that change now. |
Applied as fe1bfb7. Thanks! |
The culprit is the too restrictive fix for bug #71536, which prevents
php_libxml_streams_IO_write()
from properly executing when uncleanshutdown is flagged. However, the fix for bug #79029 already prevents
that call during shutdown in the first place, so that it actually fixes
bug #71536 as well. Thus, we can just revert the original fix for bug
#71536.
Thanks to bwoebi and daverandom for helping to investigate this issue.