[xml/sgml-pkgs] Bug#590934: Bug#590934: libxml2: Segmentation fault, when compiling with -static

Christoph Junghans junghans at votca.org
Mon Aug 2 10:21:40 UTC 2010


How do you check if a weak symbol was resolved?

2010/8/2 Mike Hommey <mh at glandium.org>:
> On Fri, Jul 30, 2010 at 11:53:17AM +0200, Christoph Junghans <junghans at votca.org> wrote:
>> Package: libxml2
>> Version: 2.6.32.dfsg-5+lenny1
>>
>> I know static compiling is bad, but from time to time you need it.
>>
>> 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 -lz -lm
>> $ ./a.out
>> Segmentation fault
>>
>> This is a problem with weak symbols in threads.c
>>
>> A patch can be found here:
>> https://bugzilla.gnome.org/show_bug.cgi?id=609926
>> but upstream refused to merge it.
>
> Upstream is partially responsible for the problem. I'd say there are actually
> 2 different problems. The first one is that despite using weak symbols, the
> initialization steps don't check if the symbols are resolved before using
> them. That should IMHO be fixed in libxml2, instead of removing weak symbols.
> The fix should be straightforward.
>
> The other issue is that gcc and ld are doing weird stuff with those weak
> pthread symbols, even when using -lpthread. I'll probably file a bug against
> either or both.
>
> Please also note that you should be using the "--libs --static" options when
> linking statically libxml2, which gives the right flags, but due to the above,
> that doesn't buy much.
>
> Cheers,
>
> Mike
>





More information about the debian-xml-sgml-pkgs mailing list