[xml] Segfault because of unresolved pthread functions



My program built with libxml2 is segfaulting at line 434 of threads.c:
pthread_mutex_lock(&global_init_lock);

It seems that the function pthread_mutex_lock has been given address 0 by the linker, so when this function gets called it calls address 0 and crashes.

I discovered that in threads.c, various pthread functions are redeclared with __attribute((weak)), which suppresses ld's warning that the symbol is unresolved. So the executable gets built anyway, with the function address set to 0, and crashes.

If I build my program without -lpthread, I get unresolved symbol errors for pthread_cond_wait and pthread_cond_destroy.

I tried turning off --with-threads in the libxml2 build configuration, but I still get unresolved symbol errors for the above pthread functions. It looks like the #ifdefs which preprocess out those functions in threads.c are conditional on the presence of pthread.h on the system, rather than on the config option --without-threads.

Do you have any suggestions for making this work, i.e. build and not crash? (Preferably --with-threads, but failing that --without-threads will do.)

Thanks,
Rachael





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]