The following perl one-liner crashes on my system with a segmentation fault: perl -e 'use XML::LibXML; use GD;' All components used here (perl, p5-XML-LibXML, p5-GD) are installed as packages. Interestingly, if I swap both use statements, then there's no crash: perl -e 'use GD; use XML::LibXML' I could also reproduce the problem with self-compiled perls (5.10.1, 5.14.2, 5.16.0) and the latest module versions from CPAN. Some of this perls did not produce a segfault, but an endless loop in the global destruction phase. Only with a perl with compiled-in threading there was no problem. The backtrace looks like following: #0 0x000000080508935b in pthread_mutex_lock () from /lib/libthr.so.3 #1 0x0000000803b436c5 in xmlRMutexLock () from /usr/local/lib/libxml2.so.5 #2 0x0000000803b3eb0c in xmlCatalogCleanup () from /usr/local/lib/libxml2.so.5 #3 0x0000000803adbbda in xmlCleanupParser () from /usr/local/lib/libxml2.so.5 #4 0x000000080383eac4 in XS_XML__LibXML_END (cv=0xf343c8) at LibXML.xs:1566 #5 0x00000000004eab56 in Perl_pp_entersub () at pp_hot.c:2778 #6 0x000000000043f36d in Perl_call_sv (sv=0xf343c8, flags=13) at perl.c:2705 #7 0x000000000044444a in Perl_call_list (oldscope=1, paramList=0xf343e0) at perl.c:4782 #8 0x000000000043a3cf in perl_destruct (my_perl=0x802735220) at perl.c:565 #9 0x000000000041ddc2 in main (argc=2, argv=0x7fffffffccb0, env=0x7fffffffccc8) at perlmain.c:131 If the problem caused an endless loop (see above), then this loop happens at the same place, somewhere after pthread_mutex_lock. Regards, Slaven Fix: Sorry, none known, other than the workaround of swapping both "use" statements, which is often not feasible in complex systems. How-To-Repeat: See above.
Responsible Changed From-To: freebsd-ports-bugs->swills I'll take it.
Hi, I tried to reproduce this but was unable to: pr171353# perl -e 'use XML::LibXML; use GD;' pr171353#=20 This is in a jail I setup just for testing this. For the record, I tried = both locally built packages and packages from pkgbeta, both installed = using pkgng... So, could you please send output of perl -V? For the record, here's = mine: pr171353# perl -V Summary of my perl5 (revision 5 version 14 subversion 2) configuration: =20 Platform: osname=3Dfreebsd, osvers=3D9.0-release, archname=3Damd64-freebsd uname=3D'freebsd tinderbox.host 9.0-release freebsd 9.0-release #0: = sat sep 1 02:55:19 edt 2012 root@tinderbox.host:usrsrcsysmagickernelpath = amd64 ' config_args=3D'-sde -Dprefix=3D/usr/local = -Darchlib=3D/usr/local/lib/perl5/5.14.2/mach = -Dprivlib=3D/usr/local/lib/perl5/5.14.2 = -Dman3dir=3D/usr/local/lib/perl5/5.14.2/perl/man/man3 = -Dman1dir=3D/usr/local/man/man1 = -Dsitearch=3D/usr/local/lib/perl5/site_perl/5.14.2/mach = -Dsitelib=3D/usr/local/lib/perl5/site_perl/5.14.2 = -Dscriptdir=3D/usr/local/bin = -Dsiteman3dir=3D/usr/local/lib/perl5/5.14.2/man/man3 = -Dsiteman1dir=3D/usr/local/man/man1 -Ui_malloc -Ui_iconv = -Uinstallusrbinperl -Dcc=3Dcc -Duseshrplib -Dinc_version_list=3Dnone = -Dccflags=3D-DAPPLLIB_EXP=3D"/usr/local/lib/perl5/5.14.2/BSDPAN" = -Doptimize=3D-O2 -pipe -fno-strict-aliasing -Ui_gdbm -Dusethread s=3Dn -Dusemymalloc=3Dn -Duse64bitint' hint=3Drecommended, useposix=3Dtrue, d_sigaction=3Ddefine = useithreads=3Dundef, usemultiplicity=3Dundef useperlio=3Ddefine, = d_sfio=3Dundef, uselargefiles=3Ddefine, usesocks=3Dundef = use64bitint=3Ddefine, use64bitall=3Ddefine, uselongdouble=3Dundef = usemymalloc=3Dn, bincompat5005=3Dundef Compiler: cc=3D'cc', ccflags = =3D'-DAPPLLIB_EXP=3D"/usr/local/lib/perl5/5.14.2/BSDPAN" -DHAS_FPSETMASK = -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector=20 -I/usr/local/include', optimize=3D'-O2 -pipe -fno-strict-aliasing', cppflags=3D'-DAPPLLIB_EXP=3D"/usr/local/lib/perl5/5.14.2/BSDPAN" = -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe = -fstack-protector -I/usr/lo cal/include' ccversion=3D'', gccversion=3D'4.2.1 20070831 patched = [FreeBSD]', gccosandvers=3D'' intsize=3D4, longsize=3D8, ptrsize=3D8, doublesize=3D8, = byteorder=3D12345678 d_longlong=3Ddefine, longlongsize=3D8, d_longdbl=3Ddefine, = longdblsize=3D16 ivtype=3D'long', ivsize=3D8, nvtype=3D'double', nvsize=3D8, = Off_t=3D'off_t', lseeksize=3D8 alignbytes=3D8, prototype=3Ddefine Linker and Libraries: ld=3D'cc', ldflags =3D'-pthread -Wl,-E -fstack-protector = -L/usr/local/lib' libpth=3D/usr/lib /usr/local/lib libs=3D-lm -lcrypt -lutil perllibs=3D-lm -lcrypt -lutil libc=3D, so=3Dso, useshrplib=3Dtrue, libperl=3Dlibperl.so gnulibc_version=3D'' Dynamic Linking: dlsrc=3Ddl_dlopen.xs, dlext=3Dso, d_dlsymun=3Dundef, ccdlflags=3D' = -Wl,-R/usr/local/lib/perl5/5.14.2/mach/CORE' cccdlflags=3D'-DPIC -fPIC', lddlflags=3D'-shared -L/usr/local/lib = -fstack-protector' Characteristics of this binary (from libperl):=20 Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF Built under freebsd Compiled at Sep 1 2012 07:02:47 @INC: /usr/local/lib/perl5/5.14.2/BSDPAN /usr/local/lib/perl5/site_perl/5.14.2/mach /usr/local/lib/perl5/site_perl/5.14.2 /usr/local/lib/perl5/5.14.2/mach /usr/local/lib/perl5/5.14.2 . pr171353#=20 Also, are you changing any of the default options for either perl or the = two modules in question? And have the perl modules been rebuilt since = perl was rebuilt? Thanks, Steve
Steve Wills <swills@FreeBSD.org> writes: > So, could you please send output of perl -V? For the record, here's mine: Here's mine: Summary of my perl5 (revision 5 version 12 subversion 4) configuration: Platform: osname=freebsd, osvers=9.0-rc2, archname=amd64-freebsd uname='freebsd freebsd.org 9.0-rc2 freebsd 9.0-rc2 #0: mon dec 5 15:11:44 utc 2011 kris@freebsd.org:usrsrcsysmagickernelpath amd64 ' config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.12.4/mach -Dprivlib=/usr/local/lib/perl5/5.12.4 -Dman3dir=/usr/local/lib/perl5/5.12.4/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.12.4/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.12.4 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.12.4/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dinc_version_list=none -Dccfl ags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.12.4/BSDPAN" -Doptimize=-O2 -pipe -fno-strict-aliasing -Ui_gdbm -Dusethreads=n -Dusemymalloc=n -Duse64bitint' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.12.4/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include', optimize='-O2 -pipe -fno-strict-aliasing', cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.12.4/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.2.1 20070831 patched [FreeBSD]', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -Wl,-E -fstack-protector -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lm -lcrypt -lutil perllibs=-lm -lcrypt -lutil libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-R/usr/local/lib/perl5/5.12.4/mach/CORE' cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF Built under freebsd Compiled at Dec 5 2011 15:24:07 %ENV: PERLDOC="-MPod::Perldoc::ToTextOverstrike" PERL_HTML_DISPLAY_CLASS="HTML::Display::Mozilla" @INC: /usr/local/lib/perl5/5.12.4/BSDPAN /usr/local/lib/perl5/site_perl/5.12.4/mach /usr/local/lib/perl5/site_perl/5.12.4 /usr/local/lib/perl5/5.12.4/mach /usr/local/lib/perl5/5.12.4 . > > Also, are you changing any of the default options for either perl or the two modules in question? And have the perl modules been rebuilt since perl was rebuilt? > No --- everything was installed using 9.0-release packages. Regards, Slaven -- Slaven Rezic - slaven <at> rezic <dot> de BBBike - route planner for cyclists in Berlin WWW version: http://www.bbbike.de Perl/Tk version for Unix and Windows: http://bbbike.sourceforge.net
Ok, I believe the fix for this is to have a perl built with -pthread = (note this is not the same as a threaded perl). This was added to the = lang/perl* ports in February, shortly after 9.0 was released. So, the = easiest solution is to rebuild using the newer perl port (and then = rebuild all p5- ports) or wait for 9.1 packages. Steve
State Changed From-To: open->closed Issue already fixed.
Steve Wills <swills@FreeBSD.org> writes: > Ok, I believe the fix for this is to have a perl built with -pthread (note this is not the same as a threaded perl). This was added to the lang/perl* ports in February, shortly after 9.0 was released. So, the easiest solution is to rebuild using the newer perl port (and then rebuild all p5- ports) or wait for 9.1 packages. Thanks, this indeed fixes the problem. Should this problem be addressed further? perl's freebsd hints file does not specify -pthread by default. So anybody building perl without ports, or disabling the -pthread option when building perl using the port, will have the same problem. I just checked and it seems that for a fix it's enough to add -pthread to the LDLOADLIBS variable in XML::LibXML's generated Makefile. XML::LibXML is using the output of `xml2-config --libs` as the value of LDLOADLIBS. Here -pthread is missing. So should libxml's xml2-config be patched? Regards, Slaven -- Slaven Rezic - slaven <at> rezic <dot> de Berlin Perl Mongers - http://berlin.pm.org
On 09/08/12 10:58, Slaven Rezic wrote: > Steve Wills <swills@FreeBSD.org> writes: > I just checked and it seems that for a fix it's enough to add -pthread > to the LDLOADLIBS variable in XML::LibXML's generated Makefile. > XML::LibXML is using the output of `xml2-config --libs` as the value of > LDLOADLIBS. Here -pthread is missing. So should libxml's xml2-config be > patched? > Perhaps. Try the attached patch. This adds -pthread to the libxml2 build and adds -pthread to the "xml2-config --libs" output. Theoretically, this should also mean that libthr shows up in this: # ldd /usr/local/lib/perl5/site_perl/5.14.2/mach/auto/XML/LibXML/LibXML.so /usr/local/lib/perl5/site_perl/5.14.2/mach/auto/XML/LibXML/LibXML.so: libxml2.so.5 => /usr/local/lib/libxml2.so.5 (0x801255000) libz.so.6 => /lib/libz.so.6 (0x8015a5000) libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x8017bb000) libm.so.5 => /lib/libm.so.5 (0x801ab7000) libc.so.7 => /lib/libc.so.7 (0x80084a000) # where it does not right now. I haven't verified this yet. Please test. Thanks, Steve
Hello Steve, yes, the patch looks good. What I did: * recompiled perl again without the pthread option, so libthr does not show up anymore: $ ldd `which perl` /usr/local/bin/perl: libperl.so => /usr/local/lib/perl5/5.12.4/mach/CORE/libperl.so (0x80084a000) libm.so.5 => /lib/libm.so.5 (0x800b9a000) libcrypt.so.5 => /lib/libcrypt.so.5 (0x800dbb000) libutil.so.9 => /lib/libutil.so.9 (0x800fdb000) libc.so.7 => /lib/libc.so.7 (0x8011ec000) * reinstalled libxml2 from ports after applying your patch. Now xml2-config says: $ xml2-config --libs -L/usr/local/lib -lxml2 -lz -L/usr/local/lib -liconv -lm -pthread * reinstalled p5-XML-LibXML from ports; libthr is now visible here: $ ldd /usr/local/lib/perl5/site_perl/5.12.4/mach/auto/XML/LibXML/LibXML.so /usr/local/lib/perl5/site_perl/5.12.4/mach/auto/XML/LibXML/LibXML.so: libxml2.so.5 => /usr/local/lib/libxml2.so.5 (0x801256000) libz.so.6 => /lib/libz.so.6 (0x8015a6000) libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x8017bc000) libm.so.5 => /lib/libm.so.5 (0x801ab7000) libc.so.7 => /lib/libc.so.7 (0x80084a000) libthr.so.3 => /lib/libthr.so.3 (0x801cd8000) The problematic perl one-liner is not failing after this. Regards, Slaven -- Slaven Rezic - slaven <at> rezic <dot> de Berlin Perl Mongers - http://berlin.pm.org
State Changed From-To: closed->open Reopen due to further investigation
Author: swills Date: Tue Sep 25 14:55:49 2012 New Revision: 304839 URL: http://svn.freebsd.org/changeset/ports/304839 Log: - Build with -pthread and include -pthread in xml2-config --libs output when threads are enabled PR: ports/171353 Discussed with: marcus, kwm Approved by: marcus Added: head/textproc/libxml2/files/extra-patch-threads (contents, props changed) Modified: head/textproc/libxml2/Makefile (contents, props changed) Modified: head/textproc/libxml2/Makefile ============================================================================== --- head/textproc/libxml2/Makefile Tue Sep 25 14:47:21 2012 (r304838) +++ head/textproc/libxml2/Makefile Tue Sep 25 14:55:49 2012 (r304839) @@ -13,7 +13,7 @@ PORTNAME= libxml2 PORTVERSION= 2.7.8 -PORTREVISION?= 3 +PORTREVISION?= 4 CATEGORIES?= textproc gnome MASTER_SITES= ftp://gd.tuwien.ac.at/pub/libxml/ \ ftp://xmlsoft.org/libxml2/ @@ -54,6 +54,11 @@ CONFIGURE_ARGS+= --without-schemas .if defined(WITHOUT_THREADS) CONFIGURE_ARGS+= --without-threads +.else +CPPFLAGS+= ${PTHREAD_CFLAGS} +CFLAGS+= ${PTHREAD_CFLAGS} +LDFLAGS+= ${PTHREAD_LIBS} +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-threads .endif .if defined(WITH_MEM_DEBUG) @@ -69,6 +74,10 @@ CONFIGURE_ARGS+= --with-thread-alloc .endif post-patch: +.if !defined(WITHOUT_THREADS) + @${REINPLACE_CMD} -e 's|%%PTHREAD_LIBS%%|${PTHREAD_LIBS}|' \ + ${WRKSRC}/xml2-config.in +.endif .for d in . doc doc/devhelp doc/examples @${REINPLACE_CMD} -e '/^install-data-am:/ s|install-data-local||' \ ${WRKSRC}/${d}/Makefile.in Added: head/textproc/libxml2/files/extra-patch-threads ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/textproc/libxml2/files/extra-patch-threads Tue Sep 25 14:55:49 2012 (r304839) @@ -0,0 +1,11 @@ +--- xml2-config.in.orig 2012-09-08 17:23:54.000000000 +0000 ++++ xml2-config.in 2012-09-08 17:26:22.000000000 +0000 +@@ -91,7 +91,7 @@ + echo @XML_LIBDIR@ @XML_LIBS@ + fi + else +- echo @XML_LIBDIR@ @XML_LIBS@ @WIN32_EXTRA_LIBADD@ ++ echo @XML_LIBDIR@ @XML_LIBS@ @WIN32_EXTRA_LIBADD@ %%PTHREAD_LIBS%% + fi + ;; + _______________________________________________ svn-ports-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-ports-all To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
State Changed From-To: open->closed Patch committed. Thanks for the report and testing!
State Changed From-To: closed->open - Had to revert fix because libxml2 isn't using threads, it's only thread safe.
Is this still a problem? Could you try the attached patch? I built libxml2, but not sure if the patch works. You might try playing around with it a bit if it doesn't. -- DE
I'm also not sure which module or library is pulling in libthr. Can you use ldd and show which module is linking to libthr? It appears that your perl does not, so some other library or module must be pulling it in. -- DE
I tested this on FreeBSD 11.0-STABLE r313995 amd64 using perl: - With threads - Without threads - With perl malloc I am fairly confident this is no longer an issue.