After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 698582 - Error in xmlCleanupParser
Error in xmlCleanupParser
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other Windows
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2013-04-22 15:11 UTC by Alexander Pastukhov
Modified: 2013-04-23 05:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Alexander Pastukhov 2013-04-22 15:11:13 UTC
xmlCleanupParser function in parser.c

/*...*/
xmlCleanupGlobals();
xmlResetLastError();
/*...*/

OS: Windows (but I think others too)
problem appears then I load my library on libxml in one thread and unload it in another thread.

xmlCleanupGlobals - cleans global variables.
xmlResetLastError have such code:

void
xmlResetLastError(void)
{
    if (xmlLastError.code == XML_ERR_OK) /* xmlLastError is macro!!! */
        return;
    xmlResetError(&xmlLastError);
}

here it is:
xmlError *
__xmlLastError(void) {
    if (IS_MAIN_THREAD)
	return (&xmlLastError);
    else
	return (&xmlGetGlobalState()->xmlLastError);
}

in the function xmlGetGlobalState() we create global variables again, if they are not created.
becouse of this I've got memory leak.

You should change order of the functions in xmlCleanupParser:
/*...*/
xmlResetLastError();
xmlCleanupGlobals();
/*...*/

Thank you for your work, and sorry for my english :-)
Comment 1 Daniel Veillard 2013-04-23 05:05:23 UTC
Okay, makes sense, even if xmlCleanupParser() is a very dangerous
function, that's still a bug. Fixed in git:

https://git.gnome.org/browse/libxml2/commit/?id=704d8c5e9ae911715d575abca03900591d56c040

 thanks !

Daniel