http://www.perlmonks.org?node_id=951963


in reply to Segmentation fault in DBI + XML::LibXML

Finally I got the solution.

Following advice from mje I ran the script in debugger and got this trace:

#0 0x000000080283d92d in pthread_mutex_destroy () from /lib/libthr.so +.3 #1 0x0000000801a15a15 in xmlFreeMutex () from /usr/local/lib/libxml2. +so.5 #2 0x0000000801a15455 in xmlCleanupGlobals () from /usr/local/lib/lib +xml2.so.5 #3 0x00000008019ade8a in xmlCleanupParser () from /usr/local/lib/libx +ml2.so.5 #4 0x000000080184edb3 in XS_XML__LibXML_END () from /usr/local/lib/pe +rl5/site_perl/5.10.1/mach/auto/XML/LibXML/LibXML.so #5 0x00000008006df1f4 in Perl_pp_entersub () from /usr/local/lib/perl +5/5.10.1/mach/CORE/libperl.so #6 0x000000080068c0b0 in Perl_call_sv () from /usr/local/lib/perl5/5. +10.1/mach/CORE/libperl.so #7 0x000000080068c3c3 in Perl_call_list () from /usr/local/lib/perl5/ +5.10.1/mach/CORE/libperl.so #8 0x000000080068fe5f in perl_destruct () from /usr/local/lib/perl5/5 +.10.1/mach/CORE/libperl.so #9 0x0000000000400bcc in main ()

Seems like the problem is related to a thread support (this is also stated in the article posted by perl514).

Postgresql-client library has a thread safety turned on by default, so it took me some time to get it built without thread safety support, and that worked.

I don't think this is a really good solution though because thread safety can be usefull, and the best way would be to fix the libxml. But my scripts do not use threads, so I'm safe :)

Here are some short instructions how to rebuild postgresql-client without thread safety for those who's having the same problem.

First, configure postgresql-client port to get config.log file created:

cd /usr/ports/databases/postgresql84-client/; make configure

Second, extract configure options set by ports system:

cd work/postgresql-8.4.10/; grep ./configure config.log

There'll be something like this:

./configure --with-libraries=/usr/local/lib --with-includes=/usr/local/include --enable-thread-safety --with-openssl --with-libxml --enable-integer-datetimes --enable-nls --without-gssapi --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/ --build=amd64-portbld-freebsd8.2

Remove '--enable-thread-safety' from configure command line and run it in the current dir.

After the library is configured, build and reinstall it the usual way:

cd ../../; make FORCE_PKG_REGISTER=1 reinstall clean

That's all, now the postgresql-client has no thread safety.

Thanks to perl514, mje and Anonymous Monk for suggestions!