[Mono-bugs] [Bug 74828][Blo] Changed - race in MonoEnumInfo

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 5 May 2005 00:22:32 -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=74828

--- shadow/74828	2005-05-04 23:51:34.000000000 -0400
+++ shadow/74828.tmp.21117	2005-05-05 00:22:32.000000000 -0400
@@ -1,13 +1,13 @@
 Bug#: 74828
 Product: Mono: Class Libraries
 Version: 1.1
 OS: unknown
 OS Details: 
-Status: NEW   
-Resolution: 
+Status: RESOLVED   
+Resolution: FIXED
 Severity: Unknown
 Priority: Blocker
 Component: CORLIB
 AssignedTo: lupus@ximian.com                            
 ReportedBy: james@ximian.com               
 QAContact: mono-bugs@ximian.com
@@ -58,6 +58,35 @@
 
 
 ------- Additional Comments From james@ximian.com  2005-05-04 23:51 -------
 Created an attachment (id=15072)
 patch that adds locking and avoids the race
 
+
+------- Additional Comments From miguel@ximian.com  2005-05-05 00:22 -------
+Thread 1:
+	cache is allocated (p1)
+	cache is locked (p1), enters lock
+
+Context switch
+
+Thread 2:
+	cache is allocated (p2)
+	cache is locked (p2), enters lock
+
+Context switch
+
+Thread 1:
+	cache.Add (type) (p2)
+
+Thread 2:
+	cache.Add (type) p2)
+
+So the value of p1 is discarded.
+
+The problem in general is that "cache" is modified and updated without
+a lock behind its back.
+
+The fix from James is on the right direction, I will use something
+slightly different: since this is a helper class, and its a static
+method, I will always allocte the Hashtable on the static constructor. 
+