Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 306479 - dev-libs/libxml2 segfault
Summary: dev-libs/libxml2 segfault
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL: http://bugzilla.gnome.org/show_bug.cg...
Whiteboard:
Keywords:
Depends on: 352961
Blocks:
  Show dependency tree
 
Reported: 2010-02-23 07:17 UTC by Christoph Junghans (RETIRED)
Modified: 2011-02-11 17:30 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
test program (xml_test.tgz,912 bytes, text/plain)
2010-03-01 08:11 UTC, Christoph Junghans (RETIRED)
Details
test program (xml_test.tgz,956 bytes, application/octet-stream)
2010-03-01 12:45 UTC, Christoph Junghans (RETIRED)
Details
m4 check for broken libxml2 (ax_broken_libxml.m4,783 bytes, text/plain)
2010-03-07 13:08 UTC, Christoph Junghans (RETIRED)
Details
patch to a potential segfault due to weak symbols on pthreads (libxml2-2.7.7-fix-weak-symbols.patch,1.99 KB, patch)
2010-10-16 16:40 UTC, Christoph Junghans (RETIRED)
Details | Diff
patch for libxml2-2.7.7.ebuild (libxml2-2.7.7.ebuild.patch,909 bytes, patch)
2010-10-16 16:44 UTC, Christoph Junghans (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Junghans (RETIRED) gentoo-dev 2010-02-23 07:17:18 UTC
Compiling some packages (e.g. votca-csg in sci-overlay) statically with libxml2 lead to a strange segmentation fault due to a weak symbol linking of pthreads.

However we at votca.org have not figured out how to solve this issue yet, that is the reason why we would like to have a threads use flags for libxml2, because the problem is in the thread code somewhere.

Adding a "$(use_with threads)" to the configure part is actually enough.
Comment 1 Rafał Mużyło 2010-02-23 10:08:01 UTC
For the moment, tweaking pkgconfig file (Libs.private) seems a better idea
- at least, if it would work.
Comment 2 Christoph Junghans (RETIRED) gentoo-dev 2010-02-23 11:12:18 UTC
The patch (see url), which I submitted to the libxml bug tracker does essentially that. The problem is, weaking .la files, xml2-config and pkgconfig alone doesn't help.

However I still think the threads use flag is missing.
Comment 3 Christoph Junghans (RETIRED) gentoo-dev 2010-03-01 08:11:18 UTC
Created attachment 221583 [details]
test program

This is a small test case to see the bug. 
It builds:
-a lib, libinit, which just calls xmlInitParser
-two binaries ,a dynamic and a static one

The static one will fail, when threads are enabled.
Comment 4 Christoph Junghans (RETIRED) gentoo-dev 2010-03-01 12:45:21 UTC
Created attachment 221599 [details]
test program

Better version of the test program
Comment 5 Christoph Junghans (RETIRED) gentoo-dev 2010-03-01 14:22:08 UTC
Comment on attachment 221599 [details]
test program

Unneeded, simpler case below.
Comment 6 Christoph Junghans (RETIRED) gentoo-dev 2010-03-01 14:23:59 UTC
Here is the simplest case I can imagine:
$ cat main.c
#include <libxml/parser.h>

int main(int argc, char **argv) {
            xmlInitParser();
}
$ gcc -static main.c `xml2-config --libs --cflags` -pthread
$ ./a.out
Segmentation fault
Comment 7 Christoph Junghans (RETIRED) gentoo-dev 2010-03-07 13:05:20 UTC
Actually all packages having static useflag should depend on
libxml2[-threads] or at least have a check in configure.

As far as I can see only 

sci-chemistry/gromacs[xml]
sci-chemistry/votca-csg (sci-overlay)

are affected!

Feel free to join the discussing on the libxml2 bugtracker (see url).
Comment 8 Christoph Junghans (RETIRED) gentoo-dev 2010-03-07 13:08:48 UTC
Created attachment 222469 [details]
m4 check for broken libxml2

We are using this check in the votca package...
Comment 9 Thomas Berger 2010-06-28 18:52:48 UTC
The configure option --with-threads enables the main thread support for libxml2! So it is NOT THREADSAFE without this option.

Please add it to the maintree.
Comment 10 Thomas Berger 2010-06-28 19:02:56 UTC
Link to upstream documentation: http://xmlsoft.org/threads.html
Comment 11 Christoph Junghans (RETIRED) gentoo-dev 2010-06-29 10:52:50 UTC
actually it is a problem with the weak symbol definitions, see url in the header of the bug
Comment 12 Christoph Junghans (RETIRED) gentoo-dev 2010-08-06 13:20:57 UTC
This bug is tracked under debian bug #590934:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=590934

and there is a patch to solve the issue by moving xmlInitThreads()

The patch works for me!
Comment 13 Gilles Dartiguelongue (RETIRED) gentoo-dev 2010-08-06 13:35:56 UTC
The debian patch doesn't look too bad. One needs to checks that nothing in xmlInitGlobals is needed by xmlInitThreads but other than that, it seems fine to add to portage.
Comment 14 Christoph Junghans (RETIRED) gentoo-dev 2010-08-06 14:24:45 UTC
I think this is not the case:

http://git.gnome.org/browse/libxml2/tree/threads.c#n860
Comment 15 Christoph Junghans (RETIRED) gentoo-dev 2010-10-16 16:27:12 UTC
the patch has been accepted upstream, so I think it is safe to add it.
Comment 16 Christoph Junghans (RETIRED) gentoo-dev 2010-10-16 16:40:05 UTC
Created attachment 250895 [details, diff]
patch to a potential segfault due to weak symbols on pthreads
Comment 17 Christoph Junghans (RETIRED) gentoo-dev 2010-10-16 16:44:03 UTC
Created attachment 250897 [details, diff]
patch for libxml2-2.7.7.ebuild

It also includes support for threads use flag.
Comment 18 Pacho Ramos gentoo-dev 2011-02-11 17:30:51 UTC
+*libxml2-2.7.8 (11 Feb 2011)
+
+  11 Feb 2011; Pacho Ramos <pacho@gentoo.org> -libxml2-2.7.6.ebuild,
+  +libxml2-2.7.8.ebuild, +files/libxml2-2.7.8-reactivate-script.patch,
+  +files/libxml2-2.7.8-xpath-freeing.patch,
+  +files/libxml2-2.7.8-xpath-freeing2.patch,
+  +files/libxml2-2.7.8-xpath-memory.patch:
+  Version bump including security fixes, bump to eapi3, remove old.
+