[Mono-dev] Patch to avoid some race conditions on the mono runtime

briaeros007 briaeros007 at gmail.com
Tue Aug 29 17:04:40 EDT 2006


Hello,
I'm sorry to double post this message, but I just find out that my first
post doesn't have a subject !
I'm really sorry if you have already seen the first message.


In my work, i have to use mono with a specific thread library which
permits us to see some race conditions when we use mono as a library
 in a threaded environnement . Mono with the use of this  library show
 some race conditions that i've tried to fixed. In the patch we can see
 four modifications of the file mini.c.
The first two are modifications which avoid to put two times the same
fonction in a table.
The last modification (which corresponds to the two last modifications
on the patch) was done since we have plenty of bugs which aren't
reproductibles, but all theses bugs have this fonction as a common
point. In this way we have just extend the critical section. this
modifications permits to run our tests program without any scratch.

yours sincerely

Ps : theses errors are also in the new release of mono 1.1.17.
The patch work on this version too, even if there are a "fuzz"
 without any consequences.

-------------------------------------------------------------------
Subete ga wakatta toki…watashi ga anta wo korosu.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060829/803d3530/attachment.html 
-------------- next part --------------
diff -abur mono-1.1.16.1/mono/mini/mini.c mono-1.1.16.1.1/mono/mini/mini.c
--- mono-1.1.16.1/mono/mini/mini.c	2006-07-05 23:55:50.000000000 +0200
+++ mono-1.1.16.1.1/mono/mini/mini.c	2006-08-04 09:22:11.418560308 +0200
@@ -2848,12 +2848,15 @@
 
 	info = mono_find_jit_icall_by_name (icall_name);
 	if (info == NULL) {
+	  mono_jit_lock ();
+	  info = mono_find_jit_icall_by_name (icall_name);
+	  if (info == NULL) {
 		esig = mono_get_array_new_va_signature (rank);
 		name = g_strdup (icall_name);
 		info = mono_register_jit_icall (mono_array_new_va, name, esig, FALSE);
 
-		mono_jit_lock ();
 		g_hash_table_insert (jit_icall_name_hash, name, name);
+	  }
 		mono_jit_unlock ();
 	}
 
@@ -3052,13 +3055,18 @@
 
 	info = mono_find_jit_icall_by_name (icall_name);
 	if (info == NULL) {
+	  mono_jit_lock();
+	  info = mono_find_jit_icall_by_name (icall_name);
+	  if(info==NULL){
 		esig = mono_get_element_address_signature (rank);
 		name = g_strdup (icall_name);
 		info = mono_register_jit_icall (ves_array_element_address, name, esig, FALSE);
 
-		mono_jit_lock ();
+		/*mono_jit_lock ();*/
 		g_hash_table_insert (jit_icall_name_hash, name, name);
-		mono_jit_unlock ();
+		/*mono_jit_unlock ();*/
+	  }
+	  mono_jit_unlock();
 	}
 
 	temp = mono_emit_native_call (cfg, bblock, mono_icall_get_wrapper (info), info->sig, sp, ip, FALSE, FALSE);
@@ -10284,7 +10292,6 @@
 		}
 	}
 
-	mono_domain_unlock (target_domain);
 	p = mono_create_ftnptr (target_domain, mono_jit_compile_method_inner (method, target_domain, opt));
 
 	if (callinfo) {
@@ -10296,7 +10303,7 @@
 		}
 		mono_jit_unlock ();
 	}
-
+	mono_domain_unlock (target_domain);
 	return p;
 }
 


More information about the Mono-devel-list mailing list