[Scons-users] LoadableModule on Python OSX binding generates "PyThreadState_Get: no current thread"

Marc Magrans de Abril marcmagransdeabril at gmail.com
Fri Aug 10 10:20:51 EDT 2012


Dear colleagues,

I am trying to build a "hello world" Python extension in C++ for MacOS
10.7.4 (i.e. Lion). I am using boost::python to automatically generate
the boilerplate code. Unfortunately, I am not able to generate the
module correctly. I get the following error:
$ cd boost_python
$ scons
$ export DYLD_LIBRARY_PATH=mylib/lib
$ export PYTHONPATH=mybindings/lib
$ python mytest/mytest.py
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

I have tried several combinations on the SCons w/o success. I have
been neither able to find the documentation for the LoadableModule
method. I attach the zip with the library example, a test example for
the library, the bindings, and the test example for them.

Does anybody know how to fix the file mybindings/SConstruct to make
the mytest.py example work. Here is the current version of the
SConstruct file:
import glob

env = Environment()

env.Append( CXXFLAGS=['-Wall'])
env.Append( CPPPATH=
['../mylib/include','/opt/local/include','/usr/include/python2.7'])
env.Append( LIBPATH = ['/opt/local/lib','../mylib/lib'])
env.Append( LIBS = ['python','boost_python','mylib'])

#shared library test
env.Program('bin/mylib_test','src/mylib_test.cpp')

#OSX Python module
env.LoadableModule('lib/mybindings.so', 'src/mybindings.cpp')


Thanks,
marc


PS:
------MacOS version:
$ sw_vers -productVersion
10.7.4

------SCons version:
scons -v
SCons by Steven Knight et al.:
script: v2.0.1.r5134, 2010/08/16 23:02:40, by bdeegan on cooldog
engine: v2.0.1.r5134, 2010/08/16 23:02:40, by bdeegan on cooldog
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010 The SCons Foundation

-------Boost Version:
sudo port install boost +version2.7
$ port list boost
boost @1.50.0 devel/boost

-------Core dump generated after the error:
Process: Python [60042]
Path:
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: bash [3466]

PlugIn Path:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python
PlugIn Identifier: org.python.python
PlugIn Version: 2.7.3, [c] 2004-2012 Python Software Foundation. (2.7.3)

Date/Time: 2012-08-10 14:56:23.809 +0200
OS Version: Mac OS X 10.7.4 (11E2705)
Report Version: 9

Interval Since Last Report: 866910 sec
Crashes Since Last Report: 25
Per-App Crashes Since Last Report: 23
Anonymous UUID: B8AE5B2D-45F8-4CC0-84A8-1296D93FC6B6

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
abort() called
objc[60042]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff90dbd82a __kill + 10
1 libsystem_c.dylib 0x00007fff9112ba9c abort + 177
2 org.python.python 0x000000010d56d261 Py_FatalError + 49
3 org.python.python 0x000000010d56c44c
PyThreadState_Get + 28
4 org.python.python 0x000000010d56a97a
Py_InitModule4_64 + 58
5 libboost_python.dylib 0x000000010d42aeb4
boost::python::detail::init_module(char const*, void (*)()) + 36
6 mybindings.so 0x000000010d4075bd initmybindings + 29
7 org.python.python 0x000000010d193ad6
_PyImport_LoadDynamicModule + 165
8 org.python.python 0x000000010d192246 0x10d0f8000 + 631366
9 org.python.python 0x000000010d192454 0x10d0f8000 + 631892
10 org.python.python 0x000000010d193201
PyImport_ImportModuleLevel + 1137
11 org.python.python 0x000000010d177506 0x10d0f8000 + 521478
12 org.python.python 0x000000010d0ffd32 PyObject_Call + 97
13 org.python.python 0x000000010d17bc40
PyEval_CallObjectWithKeywords + 180
14 org.python.python 0x000000010d1818d9
PyEval_EvalFrameEx + 20871
15 org.python.python 0x000000010d182cd8
PyEval_EvalCodeEx + 1996
16 org.python.python 0x000000010d182d4d PyEval_EvalCode + 54
17 org.python.python 0x000000010d19a08f 0x10d0f8000 + 663695
18 org.python.python 0x000000010d19a14f
PyRun_FileExFlags + 157
19 org.python.python 0x000000010d19b2a2
PyRun_SimpleFileExFlags + 392
20 org.python.python 0x000000010d1ab2af Py_Main + 2715
21 org.python.python 0x000000010d0f0e88 0x10d0f0000 + 3720

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fff6ccee940 rcx:
0x00007fff6ccee928 rdx: 0x0000000000000000
rdi: 0x000000000000ea8a rsi: 0x0000000000000006 rbp:
0x00007fff6ccee950 rsp: 0x00007fff6ccee928
r8: 0x00000000000003f5 r9: 0x00007fff6ccee8f8 r10:
0x00007fff90dbee62 r11: 0xffffff80002dad60
r12: 0x000000010d408d85 r13: 0x0000000000000000 r14:
0x0000000000000000 r15: 0x000000010d44f180
rip: 0x00007fff90dbd82a rfl: 0x0000000000000202 cr2: 0x000000010d5b1e60
Logical CPU: 0

Binary Images:
0x10d0f0000 - 0x10d0f0fff org.python.python (2.7.1 -
2.7.1) <87B81C86-52AD-360F-A4CB-F76E6B653037>
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
0x10d0f8000 - 0x10d213ff7 org.python.python (2.7.1 -
2.7.1) <9A76F18D-842B-3141-8FAA-E4AFE3F379FA>
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
0x10d406000 - 0x10d409fff +mybindings.so (??? - ???)
<08BB72A9-5110-3816-BDA8-28F9A98E6CF4> /Users/USER/*/mybindings.so
0x10d411000 - 0x10d44bff7 +libboost_python.dylib (??? -
???) <83FACECF-F5DF-3E58-B347-5E8ADACAA132>
/opt/local/lib/libboost_python.dylib
0x10d4a8000 - 0x10d4a8fff +libmylib.dylib (??? - ???)
<33C1CD71-A465-31F7-82DE-92321AB0157B> /Users/USER/*/libmylib.dylib
0x10d4ab000 - 0x10d5ecfe7 +org.python.python (2.7.3, [c]
2004-2012 Python Software Foundation. - 2.7.3)
<21A9B394-93C5-30C1-95D9-D47F0C3C00F8>
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python
0x7fff6ccf0000 - 0x7fff6cd24baf dyld (195.6 - ???)
<C58DAD8A-4B00-3676-8637-93D6FDE73147> /usr/lib/dyld
0x7fff8f1bb000 - 0x7fff8f231fff libc++.1.dylib (28.1.0 -
compatibility 1.0.0) <DA22E4D6-7F20-3BEA-9B89-2FBA735C2EE1>
/usr/lib/libc++.1.dylib
0x7fff8f232000 - 0x7fff8f23bff7 libsystem_notify.dylib
(80.1.0 - compatibility 1.0.0) <A4D651E3-D1C6-3934-AD49-7A104FD14596>
/usr/lib/system/libsystem_notify.dylib
0x7fff8f25b000 - 0x7fff8f2a9fff libauto.dylib (??? - ???)
<D8AC8458-DDD0-3939-8B96-B6CED81613EF> /usr/lib/libauto.dylib
0x7fff8f2eb000 - 0x7fff8f2f9fff libdispatch.dylib (187.9.0 -
compatibility 1.0.0) <1D5BE322-A9B9-3BCE-8FAC-076FB07CF54A>
/usr/lib/system/libdispatch.dylib
0x7fff8f308000 - 0x7fff8f30dfff libcache.dylib (47.0.0 -
compatibility 1.0.0) <3D114C8A-AD1F-3C78-9E8C-B8F3810740E5>
/usr/lib/system/libcache.dylib
0x7fff8f444000 - 0x7fff8f446fff libquarantine.dylib (36.6.0 -
compatibility 1.0.0) <0EBF714B-4B69-3E1F-9A7D-6BBC2AACB310>
/usr/lib/system/libquarantine.dylib
0x7fff901de000 - 0x7fff901e2fff libmathCommon.A.dylib
(2026.0.0 - compatibility 1.0.0)
<FF83AFF7-42B2-306E-90AF-D539C51A4542>
/usr/lib/system/libmathCommon.A.dylib
0x7fff901e7000 - 0x7fff901f1ff7 liblaunch.dylib (392.38.0 -
compatibility 1.0.0) <6ECB7F19-B384-32C1-8652-2463C1CF4815>
/usr/lib/system/liblaunch.dylib
0x7fff904df000 - 0x7fff9050cfe7 libSystem.B.dylib (159.1.0 -
compatibility 1.0.0) <A5108164-E3EA-3C07-AA57-239BA58808A7>
/usr/lib/libSystem.B.dylib
0x7fff90d23000 - 0x7fff90d96fff libstdc++.6.dylib (52.0.0 -
compatibility 7.0.0) <6BDD43E4-A4B1-379E-9ED5-8C713653DFF2>
/usr/lib/libstdc++.6.dylib
0x7fff90da7000 - 0x7fff90dc7fff libsystem_kernel.dylib
(1699.31.2 - compatibility 1.0.0)
<185823F1-409E-3AFD-93A9-C214013C17C8>
/usr/lib/system/libsystem_kernel.dylib
0x7fff910ea000 - 0x7fff911c7fef libsystem_c.dylib (763.13.0 -
compatibility 1.0.0) <535C622E-2C14-3DD4-98D0-EA181DF8D582>
/usr/lib/system/libsystem_c.dylib
0x7fff91280000 - 0x7fff91281fff libunc.dylib (24.0.0 -
compatibility 1.0.0) <0482C762-746D-37EB-A8C9-E1048CF70462>
/usr/lib/system/libunc.dylib
0x7fff91282000 - 0x7fff91366ed7 libobjc.A.dylib (228.0.0 -
compatibility 1.0.0) <76082BBC-446B-3355-AED5-0DBCEE600CB2>
/usr/lib/libobjc.A.dylib
0x7fff918a9000 - 0x7fff918b0fff libcopyfile.dylib (85.1.0 -
compatibility 1.0.0) <65602684-33B1-32DE-802B-050CE07659AC>
/usr/lib/system/libcopyfile.dylib
0x7fff9211f000 - 0x7fff92125fff libmacho.dylib (800.0.0 -
compatibility 1.0.0) <548BAEB6-8C4C-3B0F-AB0C-7E1C960BCAB5>
/usr/lib/system/libmacho.dylib
0x7fff922e0000 - 0x7fff922e1fff
libDiagnosticMessagesClient.dylib (??? - ???)
<3DCF577B-F126-302B-BCE2-4DB9A95B8598>
/usr/lib/libDiagnosticMessagesClient.dylib
0x7fff925ce000 - 0x7fff92610ff7 libcommonCrypto.dylib
(55010.0.0 - compatibility 1.0.0)
<A5B9778E-11C3-3F61-B740-1F2114E967FB>
/usr/lib/system/libcommonCrypto.dylib
0x7fff93251000 - 0x7fff93425ff7 com.apple.CoreFoundation
(6.7.2 - 635.21) <62A3402E-A4E7-391F-AD20-1EF20236CE1B>
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff94df3000 - 0x7fff94e2efff libsystem_info.dylib (??? -
???) <35F90252-2AE1-32C5-8D34-782C614D9639>
/usr/lib/system/libsystem_info.dylib
0x7fff958ac000 - 0x7fff958adff7 libremovefile.dylib (21.1.0 -
compatibility 1.0.0) <8901B7EE-6CA0-31F3-BBFE-BB71C90B1E49>
/usr/lib/system/libremovefile.dylib
0x7fff95da8000 - 0x7fff95db0fff libsystem_dnssd.dylib (??? -
???) <8A0F6F23-53C1-34FD-B641-4C0771C71E2A>
/usr/lib/system/libsystem_dnssd.dylib
0x7fff96e5a000 - 0x7fff96e5bff7 libsystem_sandbox.dylib (???
- ???) <96D38E74-F18F-3CCB-A20B-E8E3ADC4E166>
/usr/lib/system/libsystem_sandbox.dylib
0x7fff96f75000 - 0x7fff96f76ff7 libsystem_blocks.dylib
(53.0.0 - compatibility 1.0.0) <8BCA214A-8992-34B2-A8B9-B74DEACA1869>
/usr/lib/system/libsystem_blocks.dylib
0x7fff96f77000 - 0x7fff96f7cff7 libsystem_network.dylib (???
- ???) <DD7492F9-39FB-3E73-9028-3E1027D012B9>
/usr/lib/system/libsystem_network.dylib
0x7fff96fe6000 - 0x7fff96fe6fff libkeymgr.dylib (23.0.0 -
compatibility 1.0.0) <61EFED6A-A407-301E-B454-CD18314F0075>
/usr/lib/system/libkeymgr.dylib
0x7fff97199000 - 0x7fff9739bfff libicucore.A.dylib (46.1.0 -
compatibility 1.0.0) <38CD6ED3-C8E4-3CCD-89AC-9C3198803101>
/usr/lib/libicucore.A.dylib
0x7fff9780a000 - 0x7fff97810ff7 libunwind.dylib (30.0.0 -
compatibility 1.0.0) <1E9C6C8C-CBE8-3F4B-A5B5-E03E3AB53231>
/usr/lib/system/libunwind.dylib
0x7fff978d6000 - 0x7fff978dbfff libcompiler_rt.dylib (6.0.0 -
compatibility 1.0.0) <98ECD5F6-E85C-32A5-98CD-8911230CB66A>
/usr/lib/system/libcompiler_rt.dylib
0x7fff97eaf000 - 0x7fff97eccfff libxpc.dylib (77.19.0 -
compatibility 1.0.0) <9F57891B-D7EF-3050-BEDD-21E7C6668248>
/usr/lib/system/libxpc.dylib
0x7fff987c9000 - 0x7fff987cafff libdnsinfo.dylib (395.11.0 -
compatibility 1.0.0) <853BAAA5-270F-3FDC-B025-D448DB72E1C3>
/usr/lib/system/libdnsinfo.dylib
0x7fff987e1000 - 0x7fff987f3ff7 libz.1.dylib (1.2.5 -
compatibility 1.0.0) <30CBEF15-4978-3DED-8629-7109880A19D4>
/usr/lib/libz.1.dylib
0x7fff98e7c000 - 0x7fff98e87ff7 libc++abi.dylib (14.0.0 -
compatibility 1.0.0) <8FF3D766-D678-36F6-84AC-423C878E6D14>
/usr/lib/libc++abi.dylib
0x7fff99dbd000 - 0x7fff99dc1fff libdyld.dylib (195.6.0 -
compatibility 1.0.0) <FFC59565-64BD-3B37-90A4-E2C3A422CFC1>
/usr/lib/system/libdyld.dylib

External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 4253
thread_create: 1
thread_set_state: 12

VM Region Summary:
ReadOnly portion of Libraries: Total=61.2M resident=32.4M(53%)
swapped_out_or_unallocated=28.7M(47%)
Writable regions: Total=19.9M written=1892K(9%) resident=2456K(12%)
swapped_out=0K(0%) unallocated=17.5M(88%)

REGION TYPE VIRTUAL
=========== =======
MALLOC 11.5M
MALLOC guard page 32K
STACK GUARD 56.0M
Stack 8192K
__DATA 1756K
__LINKEDIT 50.1M
__TEXT 11.1M
__UNICODE 544K
shared memory 12K
=========== =======
TOTAL 139.0M

Model: MacBookAir5,2, BootROM MBA51.00EF.B00, 2 processors, Intel Core
i7, 2 GHz, 8 GB, SMC 2.5f4
Graphics: Intel HD Graphics 4000, Intel HD Graphics 4000, Built-In, 512 MB
Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1600 MHz, 0x80AD,
0x484D5434353153364D465238412D50422020
Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1600 MHz, 0x80AD,
0x484D5434353153364D465238412D50422020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xE9),
Broadcom BCM43xx 1.0 (5.106.198.19.21)
Bluetooth: Version 4.0.7f2, 2 service, 11 devices, 1 incoming serial ports
Network Service: Thunderbolt Ethernet, Ethernet, en2
PCI Card: Apple 57762-A0, sppci_ethernet, Thunderbolt at 102,0,0
Serial ATA Device: APPLE SSD SM512E, 500.28 GB
USB Device: hub_device, 0x8087 (Intel Corporation), 0x0024, 0x1a100000 / 2
USB Device: FaceTime HD Camera (Built-in), apple_vendor_id, 0x8510,
0x1a110000 / 3
USB Device: hub_device, 0x8087 (Intel Corporation), 0x0024, 0x1d100000 / 2
USB Device: hub_device, 0x0424 (SMSC), 0x2513, 0x1d180000 / 3
USB Device: BRCM20702 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0x1d181000 / 6
USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x821f,
0x1d181300 / 9
USB Device: Internal Memory Card Reader, apple_vendor_id, 0x8404, 0x1d183000 / 5
USB Device: Apple Internal Keyboard / Trackpad, apple_vendor_id,
0x024c, 0x1d182000 / 4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: boost_python.zip
Type: application/zip
Size: 291207 bytes
Desc: not available
Url : <http://four.pairlist.net/pipermail/scons-users/attachments/20120810/6cc43560/attachment-0001.zip>


More information about the Scons-users mailing list