-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Ignore libxml leaks #16521
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
base: master
Are you sure you want to change the base?
Ignore libxml leaks #16521
Conversation
At least on Windows with libxml2 2.11.9, calling the default entity loader leaks a couple of bytes. Since we cannot do anything about that, we ignore these leaks.
More to come soon, including a fix for |
`xmlRelaxNGParse()` calls `xmlRelaxNGInitTypes()` and that allocates memory. libxml2 recommends to call `xmlCleanupParser()` to free this memory, but we don't call this function for reasons.
We cater to two more potentially leaking libxml functions. We also need to update the `ZEND_IGNORE_LEAKS_BEGIN|END()` macros, since we now have to cater to recursion, so we need to store the original value of `_crtDbgFlag` and reset it afterwards.
As it is now, Alternatively, we could break BC (and introduce a new block scope), or introduce new macros. Anyhow, given that our MSan builds apparently don't include any external libraries (because these are not instrumented by default), it might be a good idea to have nightly Windows debug builds which could check for memory leaks. The debug heap is, however, currently only supported with cli (neither cgi nor phpdbg). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I can reproduce this.
The situation for XML schema & relaxNG is the same as for the parser initialization: the library lazy initializes and so just ignoring leaks at libxml startup isn't enough.
For soap I suspect it's because of bailouts and/or lazy initialization.
Please add a comment to the locations you added ZEND_IGNORE_LEAKS_BEGIN to document it's related to lazy initialization
At least on Windows with libxml2 2.11.9, calling the default entity loader leaks a couple of bytes. Since we cannot do anything about that, we ignore these leaks.
These leaks can be detected when running ext/zend_test/tests/observer_error_04.phpt with Windows debug heap enabled (
configure --enable-debug
;set PHP_WIN32_DEBUG_HEAP=1
; and the usual environment variables). The leaks also can be seen ten soap tests.With this patch, no further leaks are detected in ext/soap/tests, but I found some in ext/dom/tests; need to check this.