Subject: dlopen() problems
To: None <current-users@NetBSD.ORG>
From: None <Mark_Weaver@brown.edu>
List: current-users
Date: 04/01/1995 10:55:43
I'm having problems with dlopen() -- in certain circumstances, it
core dumps.
I noticed the other day that my perl5 executable, which passed all
tests when I compiled it on NetBSD-1.0, now core dumps when I try
to use the perl function "dbmopen". Unfortunately, I didn't compile
the executable with debugging information, and "where" from gdb
just gives this:
(gdb) where
#0 0x1005e75c in end ()
#1 0x10069060 in end ()
#2 0x1005fa6a in end ()
#3 0x1005f84a in end ()
I figured I probably just need to recompile it, but then I noticed
that one of the programs that perl5's Configure script runs also
core dumps, which the script doesn't deal with correctly. "fred"
is the name of the program is creates, which tests if names passed
to dlsym() need underscores. It uses dlopen() to open a shared-library
which only contains one nullary function. Stepping through fred
with gdb indicates that it crashes in dlopen.
Apparently, fred and perl are crashing for the same reason, because
gdb's "where" gives the same output (except for addrs), and the tail
of their ktraces are also the same. Here's the tail of the ktrace
for perl when it dumps core trying to load the NDBM dynamically-loaded
module:
[...]
7556 perl CALL stat
7556 perl NAMI "/usr/local/lib/perl5/netbsd/auto/NDBM_File"
7556 perl RET stat 0
7556 perl CALL stat
7556 perl NAMI "/usr/local/lib/perl5/netbsd/auto/NDBM_File/NDBM_File.so"
7556 perl RET stat 0
7556 perl CALL stat
7556 perl NAMI "/usr/local/lib/perl5/netbsd/auto/NDBM_File/NDBM_File.bs"
7556 perl RET stat 0
7556 perl CALL open
7556 perl NAMI "/usr/local/lib/perl5/netbsd/auto/NDBM_File/NDBM_File.bs"
7556 perl RET open 3
7556 perl CALL fstat
7556 perl RET fstat 0
7556 perl CALL read
7556 perl GIO fd 3 read 248 bytes
"# NDBM_File DynaLoader bootstrap file for netbsd architecture.
# Do not edit this file, changes will be lost.
# This file was automatically generated by the
# mkbootstrap routine in ExtUtils/MakeMaker.pm.
@DynaLoader::dl_resolve_using = qw();
1;
"
7556 perl RET read 248/0xf8
7556 perl CALL read
7556 perl GIO fd 3 read 0 bytes
""
7556 perl RET read 0
7556 perl CALL close
7556 perl RET close 0
7556 perl CALL open
7556 perl NAMI "/usr/local/lib/perl5/netbsd/auto/NDBM_File/NDBM_File.so"
7556 perl RET open 3
7556 perl CALL read
7556 perl GIO fd 3 read 32 bytes
"\M-@\M^F\^A\v\0 \0\0\0\^P\0\0\0\0\0\0\M-x\^A\0\0 \0\0\0\0\0\0\0\0\0\0\
\0"
7556 perl RET read 32/0x20
7556 perl CALL mmap
7556 perl RET mmap 269393920/0x100ea000
7556 perl CALL mprotect
7556 perl RET mprotect 0
7556 perl CALL mmap
7556 perl RET mmap 269406208/0x100ed000
7556 perl CALL close
7556 perl RET close 0
7556 perl PSIG SIGSEGV SIG_DFL
7556 perl NAMI "perl.core"
And yet dynamic loading works for several other modules in perl.
I suspect the bug was introduced in rtld/rtld.c on March 8, the
last time it was modified. Paul, I'd be happy to provide you with
an account on my machine if it would help, or whatever
binaries/cores/examples you need.
Mark
--------------------------------------------------------------------
Email: Mark_Weaver@brown.edu | Brown University
PGP Key: finger mhw@cs.brown.edu | Dept of Computer Science