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
Investigate xmlCleanupParser segfault with libxml2 master #2059
Comments
(libxml2 maintainer here) It seems that Nokogiri tells libxml2 to use its own memory management handlers which then call into Ruby code. Apparently, this doesn't work in an ELF destructor, probably because Ruby has already cleaned up its internal state. Maybe it's possible that Nokogiri calls Another solution on the libxml2 side is to skip the call in the destructor if custom memory management functions are installed. This seems like a good idea in any case. |
Calling a custom deallocation function in the global destructor could cause all kinds of unexpected problems. See for example sparklemotion/nokogiri#2059 Only clean up if memory is managed with malloc/free.
The check in libxml2 mentioned above is a good idea in any case. So this should be fixed in libxml2 now: https://gitlab.gnome.org/GNOME/libxml2/-/commit/956534e02ef280795a187c16f6ac04e107f23c5d Thanks for the report! |
@nwellnhof Thanks for the quick and thorough response. I've confirmed that https://gitlab.gnome.org/GNOME/libxml2/-/commit/956534e02ef280795a187c16f6ac04e107f23c5d does indeed address this problem and Nokogiri no longer segfaults. I really appreciate it! |
@flavorjones I'm always grateful if people test pre-release versions of libxml2. It's extremely valuable to find such issues as early as possible. |
Describe the bug
When using libxml2 containing this commit:
https://gitlab.gnome.org/GNOME/libxml2/-/commit/9fa3200cb366c726f7c8ef234282603bb9e8816d
Nokogiri will segfault:
To Reproduce
(1) Build libxml2 shared libraries:
(obviously your host platform may be different)
(2) Set up to use those header files and shared library:
(3) Build Nokogiri against these libraries
(4) Run any ruby script that uses Nokogiri:
Expected behavior
I would expect this to not segfault.
Additional context
I git-bisected the problem to this commit:
https://gitlab.gnome.org/GNOME/libxml2/-/commit/9fa3200cb366c726f7c8ef234282603bb9e8816d
which is related to this issue:
https://gitlab.gnome.org/GNOME/libxml2/-/issues/153
and related discussion is at:
The text was updated successfully, but these errors were encountered: