[Mono-dev] deadlock when call mono_gc_collect

sagasarate sagasarate at sina.com
Thu Oct 20 06:18:24 UTC 2016


I Embed mono in my program,It`s a multi-thread program and will call
mono_runtime_invoke in multi thread

before call i will use mono_thread_attach,it work well

but i upgrade mono to 4.6.0.125,it will deadlock on call mono_gc_collect in
main thread

I try to upgrade mono to mono-4.6.1.13,it still deadlock on same position

os is centos6.5 compile with gcc 5.3.0

> thread apply all bt
Thread 12 (Thread 0x7fffecb28700 (LWP 35708)):
#0  0x0000003bbeeaca7d in nanosleep () from /lib64/libc.so.6
#1  0x0000003bbeee1c24 in usleep () from /lib64/libc.so.6
#2  0x00000000004ea1bb in DoSleep (nMilliseconds=10) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/../../Libs/Utils/ToolsLinux.h:39
#3  0x0000000000504d03 in CDOSRouterLinkManager::OnRun (this=0x7ffff010c280)
at /mnt/hgfs/MyPrj/Libs/DOSLib/DOSRouterLinkManager.cpp:66
#4  0x000000000052e65e in CEasyThread::Execute (this=0x7ffff010c3b8) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:163
#5  0x000000000052e706 in CEasyThread::ThreadProc (pParam=0x7ffff010c3b8) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#6  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#7  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 11 (Thread 0x7fffed529700 (LWP 35707)):
#0  0x0000003bbeeaca7d in nanosleep () from /lib64/libc.so.6
#1  0x0000003bbeee1c24 in usleep () from /lib64/libc.so.6
#2  0x00000000004ea1bb in DoSleep (nMilliseconds=10) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/../../Libs/Utils/ToolsLinux.h:39
#3  0x0000000000508583 in CDOSObjectProxyServiceDefault::OnRun
(this=0x7ffff010bb00) at
/mnt/hgfs/MyPrj/Libs/DOSLib/DOSObjectProxyServiceDefault.cpp:295
#4  0x000000000052e65e in CEasyThread::Execute (this=0x7ffff010bc90) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:163
#5  0x000000000052e706 in CEasyThread::ThreadProc (pParam=0x7ffff010bc90) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#6  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#7  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 10 (Thread 0x7fffe7fff700 (LWP 35706)):
#0  0x0000003bbeeaca7d in nanosleep () from /lib64/libc.so.6
#1  0x0000003bbeee1c24 in usleep () from /lib64/libc.so.6
#2  0x00000000004ea1bb in DoSleep (nMilliseconds=10) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/../../Libs/Utils/ToolsLinux.h:39
#3  0x00000000004fbccb in CDOSObjectGroup::OnRun (this=0x7ffff00f08a0) at
/mnt/hgfs/MyPrj/Libs/DOSLib/DOSObjectGroup.cpp:226
#4  0x000000000052e65e in CEasyThread::Execute (this=0x7ffff00f08a0) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:163
#5  0x000000000052e706 in CEasyThread::ThreadProc (pParam=0x7ffff00f08a0) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#6  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#7  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 9 (Thread 0x7fffedf2a700 (LWP 35705)):
#0  0x0000003bbeeaca7d in nanosleep () from /lib64/libc.so.6
#1  0x0000003bbeee1c24 in usleep () from /lib64/libc.so.6
#2  0x00000000004ea1bb in DoSleep (nMilliseconds=10) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/../../Libs/Utils/ToolsLinux.h:39
#3  0x0000000000503c5a in CDOSRouter::OnRun (this=0x7ffff00f0480) at
/mnt/hgfs/MyPrj/Libs/DOSLib/DOSRouter.cpp:78
#4  0x000000000052e65e in CEasyThread::Execute (this=0x7ffff00f0480) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:163
#5  0x000000000052e706 in CEasyThread::ThreadProc (pParam=0x7ffff00f0480) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#6  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#7  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 8 (Thread 0x7fffef02c700 (LWP 35704)):
#0  0x0000003bbeee8f33 in epoll_wait () from /lib64/libc.so.6
#1  0x0000000000523c88 in CEpollThread::OnRun (this=0x7ffff00efe40) at
/mnt/hgfs/MyPrj/Libs/NetLib/EpollThread.cpp:135
#2  0x000000000052e65e in CEasyThread::Execute (this=0x7ffff00efe40) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:163
#3  0x000000000052e706 in CEasyThread::ThreadProc (pParam=0x7ffff00efe40) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#4  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 7 (Thread 0x7fffefa2d700 (LWP 35703)):
#0  0x0000003bbeee8f33 in epoll_wait () from /lib64/libc.so.6
#1  0x0000000000523c88 in CEpollThread::OnRun (this=0x7ffff00efde0) at
/mnt/hgfs/MyPrj/Libs/NetLib/EpollThread.cpp:135
#2  0x000000000052e65e in CEasyThread::Execute (this=0x7ffff00efde0) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:163
#3  0x000000000052e706 in CEasyThread::ThreadProc (pParam=0x7ffff00efde0) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#4  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 6 (Thread 0x7fffefc8b700 (LWP 35702)):
#0  0x0000003bbf20da00 in sem_wait () from /lib64/libpthread.so.0
#1  0x000000000064ad87 in mono_os_sem_wait (flags=MONO_SEM_FLAGS_ALERTABLE,
sem=0xc4c6e0 <finalizer_sem>) at ../../mono/utils/mono-os-semaphore.h:166
#2  mono_coop_sem_wait (sem=0xc4c6e0 <finalizer_sem>,
flags=MONO_SEM_FLAGS_ALERTABLE) at ../../mono/utils/mono-coop-semaphore.h:40
#3  finalizer_thread (unused=unused at entry=0x0) at gc.c:761
#4  0x00000000006e5cea in start_wrapper_internal (data=<optimized out>) at
threads.c:740
#5  start_wrapper (data=<optimized out>) at threads.c:788
#6  0x000000000076216a in inner_start_thread (arg=<optimized out>) at
mono-threads-posix.c:92
#7  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#8  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 5 (Thread 0x7ffff5bff700 (LWP 35701)):
#0  0x0000003bbf20b68c in pthread_cond_wait@@GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1  0x000000000071bcfb in mono_os_cond_wait (mutex=0xc54ca0 <lock>,
cond=0xc54c60 <work_cond>) at ../../mono/utils/mono-os-mutex.h:107
#2  thread_func (thread_data=0x0) at sgen-thread-pool.c:110
#3  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#4  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 4 (Thread 0x7ffff6ae0700 (LWP 35700)):
#0  0x0000003bbf20da00 in sem_wait () from /lib64/libpthread.so.0
#1  0x000000000069a1a8 in mono_os_sem_wait (flags=MONO_SEM_FLAGS_NONE,
sem=0xc4d8a0 <suspend_ack_semaphore>) at
../../mono/utils/mono-os-semaphore.h:166
#2  sgen_wait_for_suspend_ack (count=count at entry=1) at sgen-os-posix.c:160
#3  0x000000000069a2df in sgen_thread_handshake (suspend=suspend at entry=1) at
sgen-os-posix.c:195
#4  0x00000000006a2d6a in sgen_client_stop_world
(generation=generation at entry=0) at sgen-stw.c:227
#5  0x000000000072381a in sgen_stop_world (generation=0) at sgen-gc.c:3219
#6  0x0000000000723c27 in sgen_perform_collection (requested_size=0,
generation_to_collect=0, reason=0x8a6a3d "user request", wait_to_finish=1,
stw=1) at sgen-gc.c:2253
#7  0x0000000000723f52 in sgen_gc_collect (generation=0) at sgen-gc.c:2692
#8  0x00000000004d810d in CDOSMainThread::Update (this=0xbd83a0
<CStaticObject<CDOSMainThread>::m_Instance>, ProcessPacketLimit=32) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/DOSMainThread.cpp:293
#9  0x00000000004e71d5 in CDOSServerThread::OnRun (this=0xbd83a0
<CStaticObject<CDOSMainThread>::m_Instance>) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/DOSServerThread.cpp:303
#10 0x00000000004e5776 in CDOSServerThread::Execute (this=0xbd83a0
<CStaticObject<CDOSMainThread>::m_Instance>) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/DOSServerThread.cpp:29
#11 0x000000000052e706 in CEasyThread::ThreadProc (pParam=0xbd83a0
<CStaticObject<CDOSMainThread>::m_Instance>) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#12 0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#13 0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 3 (Thread 0x7ffff74e1700 (LWP 35699)):
#0  0x0000003bbeeaca7d in nanosleep () from /lib64/libc.so.6
#1  0x0000003bbeee1c24 in usleep () from /lib64/libc.so.6
#2  0x00000000004ea1bb in DoSleep (nMilliseconds=10) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/../../Libs/Utils/ToolsLinux.h:39
#3  0x00000000005448a4 in CAsyncLogWorkThread::OnRun (this=0xcb3e98) at
/mnt/hgfs/MyPrj/Libs/Utils/AsyncLogWorkThread.cpp:26
#4  0x000000000052e65e in CEasyThread::Execute (this=0xcb3e98) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:163
#5  0x000000000052e706 in CEasyThread::ThreadProc (pParam=0xcb3e98) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#6  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#7  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7ffff7ee2700 (LWP 35698)):
#0  0x0000003bbeeaca7d in nanosleep () from /lib64/libc.so.6
#1  0x0000003bbeee1c24 in usleep () from /lib64/libc.so.6
#2  0x00000000004ea1bb in DoSleep (nMilliseconds=10) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/../../Libs/Utils/ToolsLinux.h:39
#3  0x00000000005448a4 in CAsyncLogWorkThread::OnRun (this=0xcb3e00) at
/mnt/hgfs/MyPrj/Libs/Utils/AsyncLogWorkThread.cpp:26
#4  0x000000000052e65e in CEasyThread::Execute (this=0xcb3e00) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:163
#5  0x000000000052e706 in CEasyThread::ThreadProc (pParam=0xcb3e00) at
/mnt/hgfs/MyPrj/Libs/Utils/EasyThreadLinux.cpp:194
#6  0x0000003bbf207aa1 in start_thread () from /lib64/libpthread.so.0
#7  0x0000003bbeee893d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7ffff7fe5780 (LWP 35694)):
#0  0x0000003bbeeaca7d in nanosleep () from /lib64/libc.so.6
#1  0x0000003bbeee1c24 in usleep () from /lib64/libc.so.6
#2  0x00000000004ea1bb in DoSleep (nMilliseconds=100) at
/mnt/hgfs/MyPrj/DistributedObjectServer/DistributedObjectServer/../../Libs/Utils/ToolsLinux.h:39
#3  0x00000000004f2c55 in CServerApp::Run (this=0xbd8d60 <theApp>) at
/mnt/hgfs/MyPrj/Libs/ServerFrameWork/ServerAppLinux.cpp:118
#4  0x00000000004f2a2b in main (argc=1, argv=0x7fffffffe658) at
/mnt/hgfs/MyPrj/Libs/ServerFrameWork/ServerAppLinux.cpp:43






--
View this message in context: http://mono.1490590.n4.nabble.com/deadlock-when-call-mono-gc-collect-tp4669023.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list