Bug 816 - tap-creator deadlock when python bindings enabled
tap-creator deadlock when python bindings enabled
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: devices
ns-3-dev
All All
: P5 normal
Assigned To: Craig Dowell
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-14 20:37 EST by Tom Goff
Modified: 2010-02-26 13:51 EST (History)
2 users (show)

See Also:


Attachments
workaround (945 bytes, patch)
2010-02-14 20:41 EST, Tom Goff
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Goff 2010-02-14 20:37:29 EST
The backtrace below shows a situation where trying to exec tap-creator
in src/devices/tap-bridge/tap-bridge.cc leads to deadlock when trying
to acquire the python GIL.  This might be due to trying to access
python objects after fork() without calling PyOS_AfterFork() to
properly reset python state (including the GIL).


#0  0x00ca1422 in __kernel_vsyscall ()
#1  0x00b8ef75 in sem_wait@@GLIBC_2.1 ()
   from /lib/tls/i686/cmov/libpthread.so.0
#2  0x081047a8 in PyThread_acquire_lock ()
#3  0x080d74fc in PyEval_RestoreThread ()
#4  0x080f83c8 in PyGILState_Ensure ()
#5  0x0100ac75 in PyNs3Node__PythonHelper::GetInstanceTypeId (this=0x9c05bc8)
    at debug/bindings/python/ns3_module_node.cc:38580
#6  0x01aa4847 in ns3::Object::DoGetObject (this=0x9c05bc8, tid=...)
    at ../src/core/object.cc:142
#7  0x01d52a2d in ns3::Object::GetObject<ns3::Ipv4> (this=0x9c05bc8)
    at debug/ns3/object.h:394
#8  0x01ebb4d5 in ns3::TapBridge::CreateTap (this=0x9bf5638)
    at ../src/devices/tap-bridge/tap-bridge.cc:373
#9  0x01eba163 in ns3::TapBridge::StartTapDevice (this=0x9bf5638)
    at ../src/devices/tap-bridge/tap-bridge.cc:220


The included patch is a workaround that moves GetObject() to before
the fork().  Creating a new ns3::fork() function would probably be a
better way to handle things more transparently.

There is also a fork() in src/devices/emu/emu-net-device.cc, but
without any python interaction before calling exec().
Comment 1 Tom Goff 2010-02-14 20:41:01 EST
Created attachment 762 [details]
workaround
Comment 2 Craig Dowell 2010-02-26 13:51:26 EST
fixed changeset 2cfc39171afd