Re: Using threads on Mac OS X using D1 and Tango
On 2013-12-15 16:28, Jacob Carlborg wrote: I'm trying to use threads on Mac OS X using D1 and Tango. I have this very simple example: import tango.core.Thread; void main () { Thread thread = new Thread({ }); thread.start(); thread.join(); } I'm using DMD 1.076 to compile the above example on Mac OS X 10.8.5 as 32bit. When I run that example I get a segmentation fault. The example works fine on Linux. If anyone is interested I found the problem. I added the following code: version( linux ) { cleanup.pop( 0 ); } else version( darwin ) { cleanup.pop( 0 ); } else version( solaris ) { cleanup.pop( 0 ); } else { pthread_cleanup_pop( 0 ); } Here: http://www.dsource.org/projects/tango/browser/trunk/tango/core/Thread.d#L275 -- /Jacob Carlborg
Using threads on Mac OS X using D1 and Tango
I'm trying to use threads on Mac OS X using D1 and Tango. I have this very simple example: import tango.core.Thread; void main () { Thread thread = new Thread({ }); thread.start(); thread.join(); } I'm using DMD 1.076 to compile the above example on Mac OS X 10.8.5 as 32bit. When I run that example I get a segmentation fault. The example works fine on Linux. Since this is so trivial example I'm expecting it's either the thread implementation in Tango that isn't working or the compiler is not generating the correct code. Does anyone know if there's a trivial fix either in the compiler or in Tango to fix this? I've tried to find difference in the thread implementation in druntime and the one in Tango. There are a few differences but none helped when I tried and modified Tango. This is the stack trace: Thread 0:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x90ed67ce mach_msg_trap + 10 1 libsystem_kernel.dylib 0x90ed5cac mach_msg + 68 2 libsystem_kernel.dylib 0x90ed0541 semaphore_create + 125 3 libsystem_c.dylib 0x91f3b441 new_sem_from_pool + 177 4 libsystem_c.dylib 0x91fcb92b pthread_join + 468 5 main 0x000ff760 D5tango4core6Thread6Thread4joinMFbZC6Object + 56 6 main0x000eef2d _Dmain + 77 7 main 0x000f597b D2rt8compiler3dmd2rt6dmain24mainUiPPaZi7runMainMFZv + 23 8 main 0x000f58ae D2rt8compiler3dmd2rt6dmain24mainUiPPaZi7tryExecMFDFZvZv + 42 9 main 0x000f59c9 D2rt8compiler3dmd2rt6dmain24mainUiPPaZi6runAllMFZv + 65 10 main 0x000f58ae D2rt8compiler3dmd2rt6dmain24mainUiPPaZi7tryExecMFDFZvZv + 42 11 main0x000f55b1 main + 189 12 libdyld.dylib 0x9a3b7725 start + 1 Thread 1 Crashed: 0 ??? 0x1c5d8b5f 0 + 475892575 1 libsystem_c.dylib 0x91f397f7 _pthread_exit + 121 2 libsystem_c.dylib 0x91f395c0 _pthread_start + 353 3 libsystem_c.dylib 0x91f23dce thread_start + 34 -- /Jacob Carlborg