[Mono-bugs] [Bug 46650][Nor] New - Race condition in code compilation (with delegates).

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sun, 20 Jul 2003 18:51:08 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=46650

--- shadow/46650	Sun Jul 20 18:51:08 2003
+++ shadow/46650.tmp.24888	Sun Jul 20 18:51:08 2003
@@ -0,0 +1,332 @@
+Bug#: 46650
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: miguel@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Race condition in code compilation (with delegates).
+
+I have attached a small program that uses delegates and BeginInvoke to.
+This sample program fails *sometimes*, it is hard to reproduce, and in my
+machine it can take up to 10 minutes to show up.
+
+To run do:
+
+  mcs program.cs
+  while true; do mono program.exe; done
+
+This will eventually lock-up, takes about 10 minutes on my machine.
+
+This happens on Debian Sid and Red Hat 9;  The problem was originally
+reported by the Dashboard people.  
+
+There are a few threads that have no useful stack trace, but the ones that
+have show that there are a few Mutexes that are being acquired:
+
+   metadata_section 
+
+Being requirested by mono_ldtfn
+
+And the domain->lock
+
+These are the stacktraces from when I locked the app:
+
+(gdb) thread apply all bt
+
+Thread 9 (Thread 1085951280 (LWP 391)):
+#0  0xffffe002 in ?? ()
+
+Thread 8 (Thread 1091898672 (LWP 392)):
+#0  0xffffe002 in ?? ()
+#1  0x400d52f3 in EnterCriticalSection (section=0x40134444) at
+critical-sections.c:138
+#2  0x4002e0b9 in mono_ldftn (method=0x80f3ba8) at jit-icalls.c:20
+#3  0x080e4f88 in ?? ()
+#4  0x080e4a72 in ?? ()
+#5  0x4004365b in mono_jit_runtime_invoke (method=0x80b7868, obj=0x0,
+params=0x411507e4, exc=0x0)
+    at mini.c:6782
+#6  0x4008e956 in mono_runtime_invoke (method=0x80b7868, obj=0x0,
+params=0x411507e4, exc=0x0) at object.c:684
+#7  0x4008f4d6 in mono_runtime_exec_main (method=0x80b7868, args=0x8063f60,
+exc=0x0) at object.c:1042
+#8  0x4008f0f3 in mono_runtime_run_main (method=0x80b7868, argc=0,
+argv=0xbfffdbbc, exc=0x0) at object.c:910
+#9  0x400649af in mono_jit_exec (domain=0x805ef80, assembly=0x80b1bb0,
+argc=1, argv=0xbfffdbb8)
+    at driver.c:432
+#10 0x40064a71 in main_thread_handler (user_data=0xbfffdb20) at driver.c:459
+#11 0x400a976f in start_wrapper (data=0x80f2d90) at threads.c:198
+#12 0x400e246c in timed_thread_start_routine (args=0x80f2da8) at
+timed-thread.c:115
+#13 0x40144687 in GC_start_routine (arg=0x805b620) at linux_threads.c:1663
+#14 0x4021a332 in start_thread () from /lib/tls/libpthread.so.0
+
+Thread 7 (Thread 1093999920 (LWP 393)):
+#0  0xffffe002 in ?? ()
+#1  0x400d52f3 in EnterCriticalSection (section=0x805ef84) at
+critical-sections.c:138
+#2  0x4008de66 in mono_class_vtable (domain=0x805ef80, class=0x8266cd8) at
+object.c:355
+#3  0x400435f9 in mono_jit_compile_method (method=0x8266c88) at mini.c:6763
+#4  0x4008d98a in mono_compile_method (method=0x8266c88) at object.c:172
+#5  0x4007e8f8 in x86_magic_trampoline (eax=135051192, ecx=136669529,
+edx=136735880, esi=136523584, 
+    edi=136523584, ebx=135051192, code=0x825697f "\213ShX", m=0x8266c88)
+at tramp-x86.c:88
+#6  0x080924bd in ?? ()
+#7  0x0825684b in ?? ()
+#8  0x082567c9 in ?? ()
+#9  0x08255b65 in ?? ()
+#10 0x0816afdd in ?? ()
+#11 0x080e534a in ?? ()
+#12 0x080e4d4d in ?? ()
+#13 0x080e5680 in ?? ()
+#14 0x4004365b in mono_jit_runtime_invoke (method=0x80f4b50, obj=0x8069ed0,
+params=0x413517c8, exc=0x8068ea0)
+    at mini.c:6782
+#15 0x4008e956 in mono_runtime_invoke (method=0x80f4b50, obj=0x8069ed0,
+params=0x413517c8, exc=0x8068ea0)
+    at object.c:684
+#16 0x4008f734 in mono_runtime_invoke_array (method=0x80f4b50,
+obj=0x8069ed0, params=0x8063f30, exc=0x8068ea0)
+    at object.c:1124
+#17 0x400910ce in mono_message_invoke (target=0x8069ed0, msg=0x8068e80,
+exc=0x8068ea0, out_args=0x805b2f8)
+    at object.c:2165
+#18 0x400aabfc in mono_async_invoke (ares=0x80caf78) at threadpool.c:50
+#19 0x400ab0b5 in async_invoke_thread () at threadpool.c:205
+#20 0x400a976f in start_wrapper (data=0x81169d0) at threads.c:198
+#21 0x400e246c in timed_thread_start_routine (args=0x81169e8) at
+timed-thread.c:115
+#22 0x40144687 in GC_start_routine (arg=0x805b240) at linux_threads.c:1663
+#23 0x4021a332 in start_thread () from /lib/tls/libpthread.so.0
+
+Thread 6 (Thread 1096101168 (LWP 394)):
+#0  0xffffe002 in ?? ()
+
+Thread 5 (Thread 1098202416 (LWP 395)):
+#0  0xffffe002 in ?? ()
+#1  0x400d52f3 in EnterCriticalSection (section=0x40134444) at
+critical-sections.c:138
+#2  0x4007e8ea in x86_magic_trampoline (eax=136464256, ecx=1075136536,
+edx=136746168, esi=134643776, 
+    edi=134643776, ebx=1075000892, code=0x82576c9
+"\203\f\213E\211E\0349\006\b\213M\211\b", 
+    m=0x82694b8) at tramp-x86.c:87
+#3  0x080924bd in ?? ()
+#4  0x0825761c in ?? ()
+#5  0x4004365b in mono_jit_runtime_invoke (method=0x8266be8, obj=0x0,
+params=0x0, exc=0x4175366c)
+    at mini.c:6782
+#6  0x4008e956 in mono_runtime_invoke (method=0x8266be8, obj=0x0,
+params=0x0, exc=0x4175366c) at object.c:684
+#7  0x4008d775 in mono_runtime_class_init (vtable=0x824e284) at object.c:102
+#8  0x0825692b in ?? ()
+#9  0x0825684b in ?? ()
+#10 0x082567c9 in ?? ()
+#11 0x08255b65 in ?? ()
+#12 0x0816afdd in ?? ()
+#13 0x080e534a in ?? ()
+#14 0x080e4d4d in ?? ()
+#15 0x080e5680 in ?? ()
+#16 0x4004365b in mono_jit_runtime_invoke (method=0x80f4b50, obj=0x8069c30,
+params=0x417537c8, exc=0x8068d20)
+    at mini.c:6782
+#17 0x4008e956 in mono_runtime_invoke (method=0x80f4b50, obj=0x8069c30,
+params=0x417537c8, exc=0x8068d20)
+    at object.c:684
+#18 0x4008f734 in mono_runtime_invoke_array (method=0x80f4b50,
+obj=0x8069c30, params=0x8063df8, exc=0x8068d20)
+    at object.c:1124
+#19 0x400910ce in mono_message_invoke (target=0x8069c30, msg=0x8068d00,
+exc=0x8068d20, out_args=0x80d2df8)
+    at object.c:2165
+#20 0x400aabfc in mono_async_invoke (ares=0x80cad70) at threadpool.c:50
+#21 0x400ab0b5 in async_invoke_thread () at threadpool.c:205
+#22 0x400a976f in start_wrapper (data=0x8160cb8) at threads.c:198
+#23 0x400e246c in timed_thread_start_routine (args=0x8140c48) at
+timed-thread.c:115
+#24 0x40144687 in GC_start_routine (arg=0x80d2d80) at linux_threads.c:1663
+#25 0x4021a332 in start_thread () from /lib/tls/libpthread.so.0
+
+Thread 4 (Thread 1100303664 (LWP 396)):
+#0  0xffffe002 in ?? ()
+#1  0x400d52f3 in EnterCriticalSection (section=0x40134444) at
+critical-sections.c:138
+#2  0x4002e0b9 in mono_ldftn (method=0x80f4b50) at jit-icalls.c:20
+#3  0x080e5672 in ?? ()
+#4  0x4004365b in mono_jit_runtime_invoke (method=0x80f4b50, obj=0x8069c00,
+params=0x419547c8, exc=0x8068ca0)
+    at mini.c:6782
+#5  0x4008e956 in mono_runtime_invoke (method=0x80f4b50, obj=0x8069c00,
+params=0x419547c8, exc=0x8068ca0)
+    at object.c:684
+#6  0x4008f734 in mono_runtime_invoke_array (method=0x80f4b50,
+obj=0x8069c00, params=0x8063db0, exc=0x8068ca0)
+    at object.c:1124
+#7  0x400910ce in mono_message_invoke (target=0x8069c00, msg=0x8068c80,
+exc=0x8068ca0, out_args=0x80d2d98)
+    at object.c:2165
+#8  0x400aabfc in mono_async_invoke (ares=0x80cabe0) at threadpool.c:50
+#9  0x400ab0b5 in async_invoke_thread () at threadpool.c:205
+#10 0x400a976f in start_wrapper (data=0x81a1988) at threads.c:198
+#11 0x400e246c in timed_thread_start_routine (args=0x81a1b20) at
+timed-thread.c:115
+#12 0x40144687 in GC_start_routine (arg=0x80d29e0) at linux_threads.c:1663
+#13 0x4021a332 in start_thread () from /lib/tls/libpthread.so.0
+
+Thread 3 (Thread 1102404912 (LWP 397)):
+#0  0xffffe002 in ?? ()
+#1  0x400d52f3 in EnterCriticalSection (section=0x40134444) at
+critical-sections.c:138
+#2  0x4002e0b9 in mono_ldftn (method=0x813a160) at jit-icalls.c:20
+#3  0x0816ad03 in ?? ()
+#4  0x0816abbc in ?? ()
+#5  0x08169d87 in ?? ()
+#6  0x08169bdc in ?? ()
+#7  0x08169b2a in ?? ()
+#8  0x080e56ef in ?? ()
+#9  0x080e533d in ?? ()
+#10 0x080e4d4d in ?? ()
+#11 0x080e5680 in ?? ()
+#12 0x4004365b in mono_jit_runtime_invoke (method=0x80f4b50, obj=0x80693f0,
+params=0x41b557c8, exc=0x8068160)
+    at mini.c:6782
+#13 0x4008e956 in mono_runtime_invoke (method=0x80f4b50, obj=0x80693f0,
+params=0x41b557c8, exc=0x8068160)
+    at object.c:684
+#14 0x4008f734 in mono_runtime_invoke_array (method=0x80f4b50,
+obj=0x80693f0, params=0x80639c0, exc=0x8068160)
+    at object.c:1124
+#15 0x400910ce in mono_message_invoke (target=0x80693f0, msg=0x8068140,
+exc=0x8068160, out_args=0x805b818)
+    at object.c:2165
+#16 0x400aabfc in mono_async_invoke (ares=0x80ca640) at threadpool.c:50
+#17 0x400ab0b5 in async_invoke_thread () at threadpool.c:205
+---Type <return> to continue, or q <return> to quit---
+#18 0x400a976f in start_wrapper (data=0x8242e78) at threads.c:198
+#19 0x400e246c in timed_thread_start_routine (args=0x8243328) at
+timed-thread.c:115
+#20 0x40144687 in GC_start_routine (arg=0x805b7a0) at linux_threads.c:1663
+#21 0x4021a332 in start_thread () from /lib/tls/libpthread.so.0
+
+Thread 2 (Thread 1104506160 (LWP 398)):
+#0  0xffffe002 in ?? ()
+#1  0x400d52f3 in EnterCriticalSection (section=0x40134444) at
+critical-sections.c:138
+#2  0x4002e0b9 in mono_ldftn (method=0x80f4b50) at jit-icalls.c:20
+#3  0x080e5672 in ?? ()
+#4  0x4004365b in mono_jit_runtime_invoke (method=0x80f4b50, obj=0x80693c0,
+params=0x41d567c8, exc=0x80680e0)
+    at mini.c:6782
+#5  0x4008e956 in mono_runtime_invoke (method=0x80f4b50, obj=0x80693c0,
+params=0x41d567c8, exc=0x80680e0)
+    at object.c:684
+#6  0x4008f734 in mono_runtime_invoke_array (method=0x80f4b50,
+obj=0x80693c0, params=0x8063978, exc=0x80680e0)
+    at object.c:1124
+#7  0x400910ce in mono_message_invoke (target=0x80693c0, msg=0x80680c0,
+exc=0x80680e0, out_args=0x805b7b8)
+    at object.c:2165
+#8  0x400aabfc in mono_async_invoke (ares=0x80ca618) at threadpool.c:50
+#9  0x400ab0b5 in async_invoke_thread () at threadpool.c:205
+#10 0x400a976f in start_wrapper (data=0x8242e78) at threads.c:198
+#11 0x400e246c in timed_thread_start_routine (args=0x8243470) at
+timed-thread.c:115
+#12 0x40144687 in GC_start_routine (arg=0x805b740) at linux_threads.c:1663
+#13 0x4021a332 in start_thread () from /lib/tls/libpthread.so.0
+
+Thread 1 (Thread 1076064480 (LWP 389)):
+#0  0xffffe002 in ?? ()
+#0  0xffffe002 in ?? ()
+(gdb) 
+(gdb) p/x 1098202416
+$4 = 0x41753d30
+(gdb) Quit
+(gdb) thread 7
+[Switching to thread 7 (Thread 1093999920 (LWP 393))]#0  0xffffe002 in ?? ()
+(gdb) up
+#1  0x400d52f3 in EnterCriticalSection (section=0x805ef84) at
+critical-sections.c:138
+138		mono_mutex_lock(&section->mutex);
+(gdb) 
+#2  0x4008de66 in mono_class_vtable (domain=0x805ef80, class=0x8266cd8) at
+object.c:355
+355		mono_domain_lock (domain);
+(gdb) 
+#3  0x400435f9 in mono_jit_compile_method (method=0x8266c88) at mini.c:6763
+6763		mono_runtime_class_init (mono_class_vtable (target_domain,
+method->klass));
+(gdb) 
+#4  0x4008d98a in mono_compile_method (method=0x8266c88) at object.c:172
+172		return default_mono_compile_method (method);
+(gdb) 
+#5  0x4007e8f8 in x86_magic_trampoline (eax=135051192, ecx=136669529,
+edx=136735880, esi=136523584, 
+    edi=136523584, ebx=135051192, code=0x825697f "\213ShX", m=0x8266c88)
+at tramp-x86.c:88
+88		addr = mono_compile_method (m);
+(gdb) list -
+78	static gpointer
+79	x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi, 
+80			      int ebx, guint8 *code, MonoMethod *m)
+81	{
+82		guint8 reg;
+83		gint32 disp;
+84		char *o;
+85		gpointer addr;
+86	
+87		EnterCriticalSection (metadata_section);
+(gdb) list
+#0  0xffffe002 in ?? ()
+#0  0xffffe002 in ?? ()
+(gdb) 
+(gdb) p/x 1098202416
+$4 = 0x41753d30
+(gdb) Quit
+(gdb) thread 7
+[Switching to thread 7 (Thread 1093999920 (LWP 393))]#0  0xffffe002 in ?? ()
+(gdb) up
+#1  0x400d52f3 in EnterCriticalSection (section=0x805ef84) at
+critical-sections.c:138
+138		mono_mutex_lock(&section->mutex);
+(gdb) 
+#2  0x4008de66 in mono_class_vtable (domain=0x805ef80, class=0x8266cd8) at
+object.c:355
+355		mono_domain_lock (domain);
+(gdb) 
+#3  0x400435f9 in mono_jit_compile_method (method=0x8266c88) at mini.c:6763
+6763		mono_runtime_class_init (mono_class_vtable (target_domain,
+method->klass));
+(gdb) 
+#4  0x4008d98a in mono_compile_method (method=0x8266c88) at object.c:172
+172		return default_mono_compile_method (method);
+(gdb) 
+#5  0x4007e8f8 in x86_magic_trampoline (eax=135051192, ecx=136669529,
+edx=136735880, esi=136523584, 
+    edi=136523584, ebx=135051192, code=0x825697f "\213ShX", m=0x8266c88)
+at tramp-x86.c:88
+88		addr = mono_compile_method (m);
+(gdb) list -
+78	static gpointer
+79	x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi, 
+80			      int ebx, guint8 *code, MonoMethod *m)
+81	{
+82		guint8 reg;
+83		gint32 disp;
+84		char *o;
+85		gpointer addr;
+86	
+87		EnterCriticalSection (metadata_section);
+(gdb) list