Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Mar 2010 18:32:38 -0600
From:      "Dustin J. Mitchell" <dustin@zmanda.com>
To:        freebsd-perl@freebsd.org
Subject:   Unthreaded Perl linked to threaded libraries
Message-ID:  <42338fbf1003091632j1fb96efdrfa0f00d2edf0a9d1@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42338fbf1003091632j1fb96efdrfa0f00d2edf0a9d1>