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!


In reply to Re: Segmentation fault in DBI + XML::LibXML by furagu
in thread Segmentation fault in DBI + XML::LibXML by furagu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.