GNOME Bugzilla – Bug 625851
segfault due to weak pthread symbols
Last modified: 2010-10-15 17:52:32 UTC
Created attachment 166996 [details] [review] Patch this is a rehash of bug 609926, because I can't reopen that one. The real issue of that bug, which is only revealed when building statically, is twofold. First, there seems to be a problem with how gcc and ld treat libpthread and libxml2's setting of weak symbols, but that's another story. Second, in xmlInitParser, both __xmlGlobalInitMutexLock and xmlInitGlobals are called before xmlInitThreads, and both use pthread symbols. __xmlGlobalInitMutexLock does so directly, without checking if the symbol exists, and xmlInitGlobals calls xmlNewMutex, which correctly depends on libxml_is_threaded... except libxml_is_threaded is still -1 by then... And again, when releasing the global mutex in __xmlGlobalInitMutexUnlock, the pthread function is called directly. The patch I'm attaching fixes that while keeping weak symbols and not affecting libxml2's behaviour regarding threads.
Also affects to Gentoo users: http://bugs.gentoo.org/show_bug.cgi?id=306479
Okay that fix is a bit more complex but the reordering should be fine. The risks sounds minimal compared to a segfault, so fine, I pushed the patch, thanks a lot ! Daniel