[Mono-bugs] [Bug 78312][Maj] New - Interlocked.Add does not return
addition result
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri May 5 20:28:36 EDT 2006
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 horst.reiterer at mind-breeze.com.
http://bugzilla.ximian.com/show_bug.cgi?id=78312
--- shadow/78312 2006-05-05 20:28:35.000000000 -0400
+++ shadow/78312.tmp.4476 2006-05-05 20:28:35.000000000 -0400
@@ -0,0 +1,65 @@
+Bug#: 78312
+Product: Mono: Class Libraries
+Version: 1.1
+OS: other
+OS Details: Red Hat Enterprise Linux 4
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: horst.reiterer at mind-breeze.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Interlocked.Add does not return addition result
+
+The current Interlocked.Add implementation returns the original value, not
+the new value resulting from the atomic addition. The following testcase
+demonstrates that behavior:
+
+using System;
+using System.Threading;
+
+public class Test
+{
+ public static void Main()
+ {
+ int test = 1;
+ int result = Interlocked.Add(ref test, 1);
+
+ if (result != 2) {
+ Console.WriteLine("Incorrect Add result: " + result);
+ }
+ }
+}
+
+According to the SDK documentation, the new value must be returned:
+
+ Return Value
+ The new value stored at location1.
+
+The testcase succeeds when being executed with the CLR.
+
+Steps to reproduce the problem:
+1. mono testcase.cs
+
+Actual Results:
+
+A return value of 1, the original value.
+
+Expected Results:
+
+A return value of 2, the new value.
+
+How often does this happen?
+
+100 out of 100 times
+
+Additional Information:
+
+Most likely, the incorrect implementation has its roots in the
+specification of Microsoft's InterlockedExchangeAdd which returns the
+original value, not the new value.
More information about the mono-bugs
mailing list