[Issue 5488] Spawned threads hang in a way that suggests allocation or gc issue

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 31 12:04:38 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5488



--- Comment #4 from Sean Kelly <sean at invisibleduck.org> 2011-01-31 12:02:19 PST ---
I've confirmed that this new deadlock isn't because the GC thread was blocked
acquiring the global thread list mutex, so I've fixed the issue this ticket was
created for.  However, it's starting to look like the Mach thread_suspend()
call doesn't play well with Posix mutexes.  What I think is happening is that a
thread is blocked on the GC mutex when a collection occurs.  The collection
completes and the mutex is released, but the thread being given the lock is
slow to resume and is missing the signal meant to notify it that the lock is
free.

This is all conjecture based on stack traces (which I'll include below) and
some printfs to confirm that core.thread isn't involved, but it seems
reasonable.  If true though, it could mean that the mechanism used to stop and
restart the world during a GC run on OSX is fundamentally unsound.  I'll see
about confirming the cause and go from there.



0x984d6142 in semaphore_wait_signal_trap ()
(gdb) bt
#0  0x984d6142 in semaphore_wait_signal_trap ()
#1  0x984dbc46 in pthread_mutex_lock ()
#2  0x0000d44e in _d_monitor_lock ()
#3  0x00010659 in _d_monitorenter ()
#4  0x0001a789 in D2gc3gcx2GC6callocMFkkPkZPv ()
#5  0x00019a78 in gc_calloc ()
#6  0x0001d5f8 in _aaGetX ()
#7  0x0001d52c in _aaGet ()
#8  0x0000a4ad in
D3std11concurrency38__T6_spawnTkTkTS3std11concurrency3TidZ6_spawnFbPFkkS3std11concurrency3TidZvkkS3std11concurrency3TidZS3std11concurrency3Tid
()
#9  0x0000a3cc in
D3std11concurrency37__T5spawnTkTkTS3std11concurrency3TidZ5spawnFPFkkS3std11concurrency3TidZvkkS3std11concurrency3TidZS3std11concurrency3Tid
()
#10 0x000026af in _Dmain ()
#11 0x0001eb77 in D2rt6dmain24mainUiPPaZi7runMainMFZv ()
#12 0x0001eafe in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
#13 0x0001ebbf in D2rt6dmain24mainUiPPaZi6runAllMFZv ()
#14 0x0001eafe in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
#15 0x0001ea8f in main ()
(gdb) thread 2
[Switching to thread 2 (process 114)]
0x0000512e in D6object12__T5clearTdZ5clearFKdZv ()
(gdb) thread 3
[Switching to thread 3 (process 114)]
0x0000512e in D6object12__T5clearTdZ5clearFKdZv ()
(gdb) thread 4
[Switching to thread 4 (process 114)]
0xffff07b6 in __memcpy ()
(gdb) thread 5
[Switching to thread 5 (process 114)]
0x984d6142 in semaphore_wait_signal_trap ()
(gdb) bt
#0  0x984d6142 in semaphore_wait_signal_trap ()
#1  0x984dbc46 in pthread_mutex_lock ()
#2  0x0000d44e in _d_monitor_lock ()
#3  0x00010659 in _d_monitorenter ()
#4  0x0001a53c in D2gc3gcx2GC6mallocMFkkPkZPv ()
#5  0x000199f3 in gc_qalloc ()
#6  0x0001f7c0 in _d_newarrayiT ()
#7  0x000272cd in
D3std11concurrency36__T4ListTS3std11concurrency7MessageZ4List3putMFS3std11concurrency7MessageZv
()
#8  0x00026efe in
D3std11concurrency10MessageBox3putMFKS3std11concurrency7MessageZv ()
#9  0x000276a9 in
D3std11concurrency33__T5_sendTS3std11concurrency3TidZ5_sendFE3std11concurrency7MsgTypeS3std11concurrency3TidS3std11concurrency3TidZv
()
#10 0x00026b87 in D3std11concurrency12_staticDtor2FZv ()
#11 0x00026a63 in _D3std11concurrency9__moddtorFZv ()
#12 0x00010596 in _moduleTlsDtor ()
#13 0x000105bf in rt_moduleTlsDtor ()
#14 0x00014bab in thread_entryPoint ()
#15 0x9850385d in _pthread_start ()
#16 0x985036e2 in thread_start ()
(gdb) thread 6
[Switching to thread 6 (process 114)]
0x984d6142 in semaphore_wait_signal_trap ()
(gdb) bt
#0  0x984d6142 in semaphore_wait_signal_trap ()
#1  0x984dbc46 in pthread_mutex_lock ()
#2  0x0000d44e in _d_monitor_lock ()
#3  0x00010659 in _d_monitorenter ()
#4  0x0001a53c in D2gc3gcx2GC6mallocMFkkPkZPv ()
#5  0x00019980 in gc_malloc ()
#6  0x0001ed7f in _d_newclass ()
#7  0x0002e3c6 in D3std8datetime3UTC12_staticCtor6FZv ()
#8  0x0002e31f in _D13datetime.11619__modctorFZv ()
#9  0x000104f4 in _moduleTlsCtor ()
#10 0x000105af in rt_moduleTlsCtor ()
#11 0x00014b8c in thread_entryPoint ()
#12 0x9850385d in _pthread_start ()
#13 0x985036e2 in thread_start ()

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list