Unthreaded Perl linked to threaded libraries
Dustin J. Mitchell
dustin at zmanda.com
Wed Mar 10 01:00:01 UTC 2010
I'm running into a problem with Amanda (http://amanda.org) on FreeBSD,
and looking for some guidance. Before anyone sends me to
amanda-users: I'm one of the Amanda developers, so the guidance I need
is related to FreeBSD and its threading.
Amanda is currently being rewritten from C into Perl, with the
interface handled by SWIG. The Perl code is all single-threaded, but
the underlying C code uses threads internally, via glib's libgthread.
Basically, Perl runs in the main thread and calls the shots, while the
C code gets the job done in threads.
The idea is that, because no part of Perl's state is ever accessed in
a thread but the main thread, this won't pose a problem.
What I'm seeing on FreeBSD 7.0 is that programs with threads but no
perl work fine, and perl programs that call into C libraries work
fine, but perl programs that call C libraries that start a thread hang
in the g_thread_create call. A truss looks like this:
4886 perl5.8.9 CALL _umtx_op(0xffffd6dc,0x3,0x1,0,0)
4886 perl5.8.9 RET _umtx_op 0
4886 perl5.8.9 CALL sigprocmask(SIG_BLOCK,0xffffd670,0x2832a0d8)
4886 perl5.8.9 RET sigprocmask 0
4886 perl5.8.9 CALL sigprocmask(SIG_SETMASK,0x2832a0d8,0)
4886 perl5.8.9 RET sigprocmask 0
4886 perl5.8.9 CALL sigprocmask(SIG_BLOCK,0xffffd5c0,0x2832a0d8)
4886 perl5.8.9 RET sigprocmask 0
4886 perl5.8.9 CALL sigprocmask(SIG_SETMASK,0x2832a0d8,0)
4886 perl5.8.9 RET sigprocmask 0
4886 perl5.8.9 CALL _umtx_op(0x2877bce0,0x11,0,0,0)
that CALL never returns.
I'm not really sure where to start figuring this out. The best I can
think of is to read the source for the _umtx_op syscall. Does anyone
have any better pointers?
Dustin
--
Open Source Storage Engineer
http://www.zmanda.com
More information about the freebsd-perl
mailing list