FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

"Bus error" when importing Pyd module on Mac

 
Post new topic   Reply to topic     Forum Index -> PyD
View previous topic :: View next topic  
Author Message
markluffel



Joined: 08 Jul 2008
Posts: 2

PostPosted: Tue Jul 08, 2008 1:18 pm    Post subject: "Bus error" when importing Pyd module on Mac Reply with quote

I've managed to get Pyd to compile (and link!) the testdll example, but I get the following error when running "import testdll" in python:

Code:

OS Version:      Mac OS X 10.5.3 (9D34)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread:  0

Thread 0 Crashed:
0   testdll.so                       0x0042137f _d_newarrayT + 111 (gc.d:269)
1   testdll.so                       0x0040ed0e _aaGetp + 414 (aaA.d:251)
2   testdll.so                       0x004069f5 _D3pyd3def20ready_module_methodsFAaZv + 128
3   testdll.so                       0x004010d1 _D3pyd3def78__T3defVG0aa0_S25_D7testdll10hello_funcFZvVAaa10_68656c6c6f5f66756e63TPFZvVk0Z3defFAaZv + 91
4   testdll.so                       0x00401074 _D3pyd3def36__T3defS25_D7testdll10hello_funcFZvZ3defFAaZv + 24
5   testdll.so                       0x00400ff0 PydMain + 46
6   testdll.so                       0x0040aefc _D7pydmain11inittestdllUZv12__dgliteral1MFZv + 48
7   testdll.so                       0x004076b6 _D3pyd9exception25__T17exception_catcherTvZ17exception_catcherFDFZvZv + 28
8   testdll.so                       0x0040aec6 inittestdll + 45
9   org.python.python                0x001a17c1 _PyImport_LoadDynamicModule + 187
10  org.python.python                0x0019ff63 PyImport_ExecCodeModule + 226
.... etc ....



I'm using the latest Pyd/Celerid from SVN and a version of GDC that I compiled (which uses DMD 1.030 internally or... however it is that GDC uses DMD...):

Code:

minami:d markluffel$ gdc -v
Using built-in specs.
Target: i686-apple-darwin9.3.0
Configured with: ../configure --prefix=/Users/markluffel/dmdgcc --enable-languages=c,d
Thread model: posix
gcc version 4.0.1 (Apple Computer, Inc. build 5363) (gdc prerelease 0.25 svn 229, using dmd 1.030)


Any ideas on what could be wrong?

Thanks!

.. Also, I have a patch that makes Celerid link properly on the Mac:
http://notlime.com/2008/pyd_mac_patch.diff
Back to top
View user's profile Send private message
markluffel



Joined: 08 Jul 2008
Posts: 2

PostPosted: Tue Jul 08, 2008 2:29 pm    Post subject: Reply with quote

Kirk suggested that the issue was that the GC wasn't being initialized, and after some searching I discovered the cause of that: Dynamic libraries on OS X >= 10.4 don't run the _init and _fini methods by default, but require you to annotate methods that should be run at load time.

http://developer.apple.com/documentation/DeveloperTools/Conceptual/DynamicLibraries/Articles/DynamicLibraryDesignGuidelines.html#//apple_ref/doc/uid/TP40002013-SW17

I've updated my patch with a fix that gets me past the GC issue.

Apparently compiling with "-framework Python" is not foolproof though, and I started to get this error instead:
"Fatal Python error: Interpreter not initialized (version mismatch?)"

The work around for this is to call a version of python that is binary compatible with the framework that your Pyd code linked against. How to figure that out? Run this:
Code:

minami:d markluffel$ otool -L testdll.so
testdll.so:
   testdll.so (compatibility version 0.0.0, current version 0.0.0)
   /Library/Frameworks/Python.framework/Versions/2.5/Python (compatibility version 2.5.0, current version 2.5.0)
   /Users/markluffel/dmdgcc/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.1)


and find the line that includes "Python.framework" and then use the python from that installation, for example "/Library/Frameworks/Python.framework/Versions/2.5/bin/python".
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> PyD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group