[Pythonmac-SIG] Problems wrapping

Robb Brown brownr at ucalgary.ca
Wed Oct 29 12:03:55 EST 2003


Okay, this is Python 2.3.2, OS X 10.2.8, GCC 3.3.

python -vv simply reports:

 >>> from dicom import *
# trying dicom.so


DYLD_PREBIND_DEBUG is the only DYLD debug variable I could find.  When  
importing Python hangs before it can report anything.


Running GDB on Python...

 >>> from dicom import *
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
^C
Program received signal SIGINT, Interrupt.
0x90034a68 in semaphore_wait_trap ()


Looks like the libraries are loading properly....

A bt shows:

(gdb) bt
#0  0x90034a68 in semaphore_wait_trap ()
#1  0x9000a3b8 in pthread_mutex_lock ()
#2  0x00713c64 in std::locale::classic() ()
#3  0x007134c0 in std::locale::locale() ()
#4  0x0070424c in std::basic_filebuf<char, std::char_traits<char>  
 >::basic_filebuf(__sFILE*, std::_Ios_Openmode, int) ()
#5  0x0070e090 in std::ios_base::Init::_S_ios_create(bool) ()
#6  0x0070e414 in std::ios_base::Init::Init() ()
#7  0x00736654 in __static_initialization_and_destruction_0(int, int) ()
#8  0x007366a8 in  
_GLOBAL__I__Z14DIMSE_echoUserP17T_ASC_Associationt20T_DIMSE_BlockingMode 
iPtPP10DcmDataset ()
#9  0x8fe16914 in __dyld_call_module_initializers_for_library ()
#10 0x8fe16690 in __dyld_call_module_initializers ()
#11 0x8fe10b54 in __dyld_link_in_need_modules ()
#12 0x8fe10590 in __dyld_bind_lazy_symbol_reference ()
#13 0x8fe01040 in __dyld_stub_binding_helper_interface ()
#14 0x00713cbc in std::locale::classic() ()
#15 0x007134c0 in std::locale::locale() ()
#16 0x0070424c in std::basic_filebuf<char, std::char_traits<char>  
 >::basic_filebuf(__sFILE*, std::_Ios_Openmode, int) ()
#17 0x0070e090 in std::ios_base::Init::_S_ios_create(bool) ()
#18 0x0070e414 in std::ios_base::Init::Init() ()
#19 0x00733b70 in __static_initialization_and_destruction_0(int, int) ()
#20 0x00736284 in _GLOBAL__I_ASC_BADPRESENTATIONCONTEXTID ()
#21 0x8fe16914 in __dyld_call_module_initializers_for_library ()
#22 0x8fe16690 in __dyld_call_module_initializers ()
#23 0x8fe10b54 in __dyld_link_in_need_modules ()
#24 0x8fe10590 in __dyld_bind_lazy_symbol_reference ()
#25 0x8fe01040 in __dyld_stub_binding_helper_interface ()
#26 0x0070424c in std::basic_filebuf<char, std::char_traits<char>  
 >::basic_filebuf(__sFILE*, std::_Ios_Openmode, int) ()
#27 0x0070e090 in std::ios_base::Init::_S_ios_create(bool) ()
#28 0x0070e414 in std::ios_base::Init::Init() ()
#29 0x00733a9c in __static_initialization_and_destruction_0(int, int) ()
#30 0x00733af0 in  
_GLOBAL__I__Z21ASC_initializeNetwork17T_ASC_NetworkRoleiiPP13T_ASC_Netwo 
rk ()
#31 0x8fe16914 in __dyld_call_module_initializers_for_library ()
#32 0x8fe16690 in __dyld_call_module_initializers ()
#33 0x8fe10b54 in __dyld_link_in_need_modules ()
#34 0x8fe10590 in __dyld_bind_lazy_symbol_reference ()
#35 0x8fe01040 in __dyld_stub_binding_helper_interface ()
#36 0x003e6c1c in std::basic_filebuf<char, std::char_traits<char>  
 >::basic_filebuf(__sFILE*, std::_Ios_Openmode, int) ()
#37 0x003f0a60 in std::ios_base::Init::_S_ios_create(bool) ()
#38 0x003f0de4 in std::ios_base::Init::Init() ()
#39 0x0041904c in __static_initialization_and_destruction_0(int, int) ()
#40 0x00419378 in _GLOBAL__I_ECC_Normal ()
#41 0x8fe16914 in __dyld_call_module_initializers_for_library ()
#42 0x8fe16690 in __dyld_call_module_initializers ()
#43 0x8fe10b54 in __dyld_link_in_need_modules ()
#44 0x8fe10590 in __dyld_bind_lazy_symbol_reference ()
#45 0x8fe01040 in __dyld_stub_binding_helper_interface ()
#46 0x00418db4 in __static_initialization_and_destruction_0(int, int) ()
#47 0x00418e24 in _GLOBAL__I__ZN9OFConsoleC2Ev ()
#48 0x8fe16914 in __dyld_call_module_initializers_for_library ()
#49 0x8fe16690 in __dyld_call_module_initializers ()
#50 0x8fe10b54 in __dyld_link_in_need_modules ()
#51 0x8fe12648 in __dyld__dyld_link_module ()
#52 0x90017268 in NSLinkModule ()
#53 0x100aeee8 in _PyImport_GetDynLoadFunc (fqname=0xe <Address 0xe out  
of bounds>, shortname=0x30 <Address 0x30 out of bounds>,  
pathname=0xbfffe6e0 "dicom.so", fp=0x30) at Python/dynload_next.c:77
#54 0x1009e7e8 in _PyImport_LoadDynamicModule (name=0x0,  
pathname=0xbfffe6e0 "dicom.so", fp=0xa0006cb8) at Python/importdl.c:42
#55 0x1009aa20 in load_module (name=0xbfffebe0 "dicom", fp=0xa0006cb8,  
buf=0xbfffe6e0 "dicom.so", type=48, loader=0xe) at Python/import.c:1708
#56 0x1009ba08 in import_submodule (mod=0x100f34e4, subname=0xbfffebe0  
"dicom", fullname=0xbfffebe0 "dicom") at Python/import.c:2290
#57 0x1009b494 in load_next (mod=0x100f34e4, altmod=0x100f34e4,  
p_name=0xa0006cb8, buf=0xbfffebe0 "dicom", p_buflen=0xbfffebe0) at  
Python/import.c:2111
#58 0x1009d6fc in import_module_ex (name=0x0, globals=0x3, locals=0x28,  
fromlist=0xb17b0) at Python/import.c:1957
#59 0x1009c5a0 in PyImport_ImportModuleEx (name=0xc8814 "dicom",  
globals=0xa89c0, locals=0xa89c0, fromlist=0xb17b0) at  
Python/import.c:1998
#60 0x100685f4 in builtin___import__ (self=0xe, args=0x3) at  
Python/bltinmodule.c:45
#61 0x1000c334 in PyObject_Call (func=0xe, arg=0x3, kw=0x28) at  
Objects/abstract.c:1755
#62 0x10074e5c in PyEval_CallObjectWithKeywords (func=0x94e68,  
arg=0x8f420, kw=0x0) at Python/ceval.c:3346
#63 0x10072930 in eval_frame (f=0x594a0) at Python/ceval.c:1996
#64 0x10073ebc in PyEval_EvalCodeEx (co=0x8f420, globals=0x3,  
locals=0xffffffdc, args=0x594a0, argcount=0, kws=0x0, kwcount=366064,  
defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2663
#65 0x10076d18 in PyEval_EvalCode (co=0xe, globals=0x3, locals=0x28) at  
Python/ceval.c:537
#66 0x100a9dcc in run_node (n=0x0, filename=0x3 <Address 0x3 out of  
bounds>, globals=0xd4d82, locals=0x594a0, flags=0x907) at  
Python/pythonrun.c:1239
#67 0x100a92e4 in PyRun_InteractiveOneFlags (fp=0x8f420,  
filename=0x576a0 "", flags=0xb18d0) at Python/pythonrun.c:731
#68 0x100a90c4 in PyRun_InteractiveLoopFlags (fp=0xc84b4,  
filename=0x95140 "", flags=0x100d90ec) at Python/pythonrun.c:664
#69 0x100aaa28 in PyRun_AnyFileExFlags (fp=0xa0000cdc,  
filename=0x100df7bc "<stdin>", closeit=0, flags=0xbffff530) at  
Python/pythonrun.c:627
#70 0x100b5b58 in Py_Main (argc=-1610609444, argv=0x100d52f4) at  
Modules/main.c:415
#71 0x00001b04 in _start (argc=-1610609444, argv=0x100d52f4, envp=0x0)  
at /SourceCache/Csu/Csu-45/crt.c:267
#72 0x00001984 in start ()


DIMSE_echoUser seems to be one of the functions that cause the problem  
(comment out the function, no problems).  This looks like the problem  
is in the dcmtk libraries... but they work fine if linked with a C++  
executable.

Thanks,

Robb



On Wednesday, October 29, 2003, at 05:17 AM, Jack Jansen wrote:

>
> On 28 Oct 2003, at 23:55, Robb Brown wrote:
>
>> Thanks for the help some of you gave a month or so ago with my  
>> project to wrap dcmtk (a DICOM medical image transmission toolkit).   
>> I've figured out how to compile it as dynamic libraries on OS X.   
>> Python wrappers work better now.  Unfortunately, there's still a  
>> problem.
>>
>> When certain functions are present, importing the module will hang  
>> Python.  Commenting out these functions lets the module import and  
>> you can use what's left.  How come this code hangs Python right when  
>> importing?
>
> See if you can find out what it does when it hangs. The first step  
> would be to use "python -vv", which will trace all imports (and all  
> places it looked before importing). The next step is to set the dyld  
> debug environment variables (see "man dyld"), which will trace the  
> dynamic loading of code. Then you could try to do a system call trace  
> (see "man ktrace") while importing. Finally you could try running  
> python under gdb, hitting control-C when it hangs and see what it's  
> doing.
> --
> Jack Jansen        <Jack.Jansen at cwi.nl>        http://www.cwi.nl/~jack
> If I can't dance I don't want to be part of your revolution -- Emma  
> Goldman
>
>
_____________________________
Robb Brown
Seaman Family MR Center
Calgary, AB




More information about the Pythonmac-SIG mailing list