Subject: pkg/28398: www/ap-perl causes Apache to dump core
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <j+nbsd@2004.salmi.ch>
List: pkgsrc-bugs
Date: 11/23/2004 17:51:01
>Number:         28398
>Category:       pkg
>Synopsis:       www/ap-perl causes Apache to dump core
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 23 17:51:01 +0000 2004
>Originator:     j+nbsd@2004.salmi.ch
>Release:        NetBSD 2.0_RC5
>Organization:
>Environment:
System: NetBSD grouper.salmi.ch 2.0_RC5 NetBSD 2.0_RC5 (GROUPER) #0: Sun Nov 14 20:31:24 UTC 2004 root@himo.salmi.ch:/build/nbsd/sys/arch/i386/compile/GROUPER i386
Architecture: i386
Machine: i386
>Description:
Using current pkgsrc on a NetBSD 2.0_RC5 i386 system, www/ap-perl does not
work (at least when used with apache-1.3.33 and perl-thread-5.8.5nb2).
While building ap-perl, the following warning is printed:

************* WARNING *************
   Your Perl is linked with -lpthread, make sure that your httpd
   is built with LIBS=-lpthread
************* WARNING *************

and that's probably exactly what causes the problem. After adding
'LoadModule perl_module lib/httpd/mod_perl.so' to httpd.conf, Apache
fails to start (abort trap) and dumps core.

>How-To-Repeat:
Build and install lang/perl58-thread, www/apache and www/ap-perl from
current pkgsrc and try to start apache:

$ /etc/rc.d/apache start
[1]   Abort trap (core dumped) ${HTTPD} -DSSL
/usr/pkg/sbin/apachectl startssl: httpd could not be started

Ktrace reveals that Apache dies shortly after reading
/usr/lib/libpthread.so.0:
[...]
 29901 httpd    CALL  open(0x480b3180,0,0xbfbfd3f0)
 29901 httpd    NAMI  "/usr/pkg/lib/libpthread.so.0"
 29901 httpd    RET   open -1 errno 2 No such file or directory
 29901 httpd    CALL  open(0x48467400,0,0xbfbfd3f0)
 29901 httpd    NAMI  "/usr/pkg/lib/perl5/5.8.5/i386-netbsd-thread-multi/CORE/libpthread.so.0"
 29901 httpd    RET   open -1 errno 2 No such file or directory
 29901 httpd    CALL  open(0x480b1700,0,0xbfbfd3f0)
 29901 httpd    NAMI  "/usr/lib/libpthread.so.0"
 29901 httpd    RET   open 5
[...]
 29901 httpd    RET   getpid 29901/0x74cd
 29901 httpd    CALL  kill(0x74cd, SIGABRT)
 29901 httpd    RET   kill 0
 29901 httpd    PSIG  SIGABRT SIG_DFL
 29901 httpd    NAMI  "httpd.core"

$ gdb /usr/pkg/sbin/httpd httpd.core                                        <
GNU gdb 5.3nb1
[...]
Loaded symbols for /usr/lib/libpthread.so.0
#0  0x48101feb in kill () from /usr/lib/libc.so.12
(gdb) bt
#0  0x48101feb in kill () from /usr/lib/libc.so.12
#1  0x481040af in __libc_mutex_unlock () from /usr/lib/libc.so.12
#2  0x48174b0d in __flockfile_internal () from /usr/lib/libc.so.12
#3  0x4815839f in fgets () from /usr/lib/libc.so.12
#4  0x08083c97 in ap_cfg_getline ()
#5  0x08072cab in ap_srm_command_loop ()
#6  0x0807321d in ap_process_resource_config ()
#7  0x08073907 in ap_read_config ()
#8  0x0807c0d5 in main ()
#9  0x080503b2 in ___start ()
(gdb) quit
$ 

>Fix:
I'm not sure whether this is the correct fix, but at least it seems to
work for me:

--- pkgsrc/www/apache/Makefile.orig       2004-11-23 12:07:15.000000000 +0100
+++ pkgsrc/www/apache/Makefile    2004-11-23 18:34:04.000000000 +0100
@@ -162,6 +162,7 @@
 .include "../../devel/libmm/buildlink3.mk"
 .include "../../textproc/expat/buildlink3.mk"
 .include "../../mk/bdb.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
 
 post-extract:
        @${CP} ${FILESDIR}/ap_include_extern.h ${WRKSRC}/src/include