[Mono-list] Named mutex causing hang at process exit

Nicholas Frechette zeno490 at gmail.com
Sat Jan 28 20:53:46 UTC 2012


Hi,
Using latest stable mono, I am getting a hang at process exit.
Mono 2.10.6 on ubuntu 11.04, x86

I know for a fact that all my threads have exited except the main
thread. It hangs when returning from main() or in Environment.Exit(0);
if I call it instead.
My shared mutex is created, released and closed properly as far as I
can tell. The hang isn't 100% either, maybe 30% and only on the
process that owns the mutex (even after it has been released).

I use MONO_ENABLE_SHM=1, mutex is used as follow:
bool created;
Mutex foo = new Mutex(true, "Global\\bar", out created);
foo.ReleaseMutex();
foo.Close();

GDB stack traces:
Thread 5 (Thread 0xb757fb70 (LWP 7128)):
#0  0x00b73416 in __kernel_vsyscall ()
#1  0x0054d48c in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/i386-linux-gnu/libpthread.so.0
#2  0x082266c8 in GC_wait_marker () at pthread_support.c:1863
#3  0x08228650 in GC_help_marker (my_mark_no=6) at mark.c:1116
#4  0x082255b2 in GC_mark_thread (id=0x0) at pthread_support.c:552
#5  0x00548e99 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#6  0x00e9773e in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 4 (Thread 0xb6642b70 (LWP 7130)):
#0  0x00b73416 in __kernel_vsyscall ()
#1  0x00550d46 in nanosleep () from /lib/i386-linux-gnu/libpthread.so.0
#2  0x081fb3c8 in collection_thread (unused=0x0) at collection.c:34
#3  0x00548e99 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#4  0x00e9773e in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 3 (Thread 0xb6611b70 (LWP 7131)):
#0  0x00b73416 in __kernel_vsyscall ()
#1  0x0054f7d5 in sem_wait@@GLIBC_2.1 ()
---Type <return> to continue, or q <return> to quit---
   from /lib/i386-linux-gnu/libpthread.so.0
#2  0x08211560 in mono_sem_wait (sem=0x82f408c, alertable=1)
    at mono-semaphore.c:113
#3  0x081282ae in finalizer_thread (unused=0x0) at gc.c:1066
#4  0x0815746e in start_wrapper_internal (data=0x9aa8db0) at threads.c:783
#5  start_wrapper (data=0x9aa8db0) at threads.c:831
#6  0x081fd9af in thread_start_routine (args=0x9a9792c) at wthreads.c:287
#7  0x08226365 in GC_start_routine (arg=0x61fe0) at pthread_support.c:1468
#8  0x00548e99 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#9  0x00e9773e in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 2 (Thread 0xb5fa3b70 (LWP 7166)):
#0  0x00b73416 in __kernel_vsyscall ()
#1  0x00550d46 in nanosleep () from /lib/i386-linux-gnu/libpthread.so.0
#2  0x081fcb58 in SleepEx (ms=1000, alertable=0) at wthreads.c:1027
#3  0x081fcc15 in Sleep (ms=1000) at wthreads.c:1050
#4  0x08154a4c in mono_thread_execute_interruption (thread=0x56738)
    at threads.c:4039
#5  0x08154d1f in mono_thread_interruption_checkpoint_request (
    bypass_abort_protection=0) at threads.c:4182
#6  0x081a7701 in tp_epoll_wait (p=0x82f4ba0)
---Type <return> to continue, or q <return> to quit---
    at ../../mono/metadata/tpool-epoll.c:99
#7  0x0815746e in start_wrapper_internal (data=0xb5e113e8) at threads.c:783
#8  start_wrapper (data=0xb5e113e8) at threads.c:831
#9  0x081fd9af in thread_start_routine (args=0x9a97bd4) at wthreads.c:287
#10 0x08226365 in GC_start_routine (arg=0xdbfe0) at pthread_support.c:1468
#11 0x00548e99 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#12 0x00e9773e in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 1 (Thread 0xb7781b60 (LWP 7127)):
#0  0x00b73416 in __kernel_vsyscall ()
#1  0x00e99b0b in semop () from /lib/i386-linux-gnu/libc.so.6
#2  0x0820baf6 in shm_sem_unlock (sem=3) at shared.c:814
#3  _wapi_shm_sem_unlock (sem=3) at shared.c:881
#4  0x081f43b0 in _wapi_handle_unlock_shared_handles (numhandles=2, handles=
    0xb5e0c2b8) at ../../mono/io-layer/handles-private.h:345
#5  _wapi_handle_unlock_handles (numhandles=2, handles=0xb5e0c2b8)
    at handles.c:1533
#6  0x081f5cc6 in handle_cleanup (data=0xbfdbfc08) at wait.c:478
#7  0x081f6044 in test_and_own (numobjects=2, handles=0xb5e0c2b8, waitall=1,
    count=0xbfdbfc9c, lowest=0xbfdbfc98) at wait.c:513
#8  0x081f6c5d in WaitForMultipleObjectsEx (numobjects=2, handles=0xb5e0c2b8,
---Type <return> to continue, or q <return> to quit---
    waitall=1, timeout=100, alertable=0) at wait.c:749
#9  0x081579ae in mono_thread_suspend_all_other_threads () at threads.c:3214
#10 0x0813bf8a in ves_icall_System_Environment_Exit (result=0) at icall.c:6546
#11 0x00632114 in ?? ()
#12 0x0014f118 in ?? ()
#13 0x0014f2ef in ?? ()
#14 0x08062398 in mono_jit_runtime_invoke (method="Cygnus.MainClass:Main ()",
    obj=0x0, params=0xbfdc00dc, exc=0x0) at mini.c:5764
#15 0x0815be2e in mono_runtime_invoke (method="Cygnus.MainClass:Main ()", obj=
    0x0, params=0xbfdc00dc, exc=0x0) at object.c:2755
#16 0x0815eb28 in mono_runtime_exec_main (method="Cygnus.MainClass:Main ()",
    args=0x61fe0, exc=0x0) at object.c:3938
#17 0x080ba5c8 in main_thread_handler (argc=6, argv=0xbfdc02c4)
    at driver.c:1003
#18 mono_main (argc=6, argv=0xbfdc02c4) at driver.c:1855
#19 0x0805724e in mono_main_with_options (argc=6, argv=0xbfdc02c4) at main.c:66
#20 main (argc=6, argv=0xbfdc02c4) at main.c:97


More information about the Mono-list mailing list