[Mono-dev] ConcurrentStack with value type in 2.10
Yuriy Solodkyy
yuriy at couldbedone.com
Tue Jul 24 10:07:15 UTC 2012
Hi All,
I just check this on fresh build mono from master.
It is not the problem that you can see on each run. You need to run
on 8-cores to observe it frequently enough.
My environment is Linux x64 (tried: ubuntu 10, ubuntu 12, opensuse 12).
Typically if you start test app and it does not crash it will not crash later.
However, I just got it again, the stack trace is below. This is just
a different favor of the same problem. Sometimes ConcurrentStack
returns inconsistent data, sometimes it crashes.
See the code sample at
https://github.com/ysw/mono-socket-problem/tree/master/ConcurrentTest
ubuntu at ip-10-244-0-134:~/mono-socket-problem/ConcurrentTest/bin/Debug$
m CocurrentTest.exe
Hello World!
Unhandled Exception:
mono() [0x49545d]
mono() [0x497079]
mono() [0x49918b]
mono() [0x4f0e67]
[0x4199f9ac]
[ERROR] FATAL UNHANDLED EXCEPTION: System.IndexOutOfRangeException:
Array index is out of range.
at (wrapper stelemref) object:virt_stelemref_class (intptr,object)
at System.Collections.Concurrent.ObjectPool`1[T].Release
(System.Collections.Concurrent.T obj) [0x00000] in <filename
unknown>:0
at System.Collections.Concurrent.ConcurrentStack`1[CocurrentTest.MainClass+Data].TryPop
(CocurrentTest.Data& result) [0x00000] in <filename unknown>:0
at CocurrentTest.MainClass+<Main>c__AnonStorey0.<>m__0
(System.Object v) [0x00000] in <filename unknown>:0
at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
ubuntu at ip-10-244-0-134:~/mono-socket-problem/ConcurrentTest/bin/Debug$
Updating https://bugzilla.xamarin.com/show_bug.cgi?id=6229 as well
--yuriy
On Mon, Jul 23, 2012 at 3:45 PM, Alan <alan.mcgovern at gmail.com> wrote:
> I cannot reproduce the problem either. What exact version of 2.10 did
> you test against? It's possible the bug has already been fixed in a
> newer release of the 2.10 series.
>
> Alan
>
> On 23 July 2012 13:32, Rodrigo Kumpera <kumpera at gmail.com> wrote:
>> Hi Yuriy,
>>
>> With how many cores and on what CPU did managed to reproduce this?
>> I'm running this on my 4 cores nehalem mac without any luck. I'll diff
>> ConcurrentStack
>> between 2.8 and 2.10 to see what could be.
>>
>> On Sun, Jul 22, 2012 at 5:10 AM, Yuriy Solodkyy <yuriy at couldbedone.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> It looks like the ConcurrentStack does not work with big enough
>>> structures anymore. 12 bytes struct is enough to reproduce the
>>> problem occasionally, 16 bytes structure to reproduce it immediately.
>>> It worked fine in mono 2.8. The following code shows that we may pop
>>> inconsistent structure from the stack from time to time.
>>>
>>> using System;
>>> using System.Collections.Concurrent;
>>> namespace CocurrentTest {
>>> class MainClass {
>>> struct Data {
>>> public int A; public int B; public int C; public
>>> int D;
>>> public Data(int v) {
>>> A = v; B = -v; C = v; D = -v;
>>> }
>>> }
>>>
>>> public static void Main (string[] args) {
>>> Console.WriteLine ("Hello World!");
>>> var data = new byte[1024 * 1024];
>>> var stack = new ConcurrentStack<Data> ();
>>>
>>> for (var i = 0; i < 50; i++) {
>>>
>>> var thread = new System.Threading.Thread
>>> (v => {
>>>
>>> var rnd = new Random ();
>>> while (true) {
>>> int pushCount = rnd.Next
>>> (50);
>>> int popCount = rnd.Next
>>> (50);
>>>
>>> for (var k = 0; k <
>>> pushCount; k++) {
>>>
>>>
>>> var sample =
>>> new Data (rnd.Next(Int32.MaxValue));
>>> CheckSample
>>> (sample);
>>>
>>> stack.Push
>>> (sample);
>>> }
>>>
>>> for (var k = 0; k <
>>> popCount; k++) {
>>> Data
>>> retrievedSample = new Data();
>>> if
>>> (stack.TryPop (out retrievedSample)) {
>>>
>>> CheckSample (retrievedSample);
>>> }
>>> }
>>> }
>>> }
>>> );
>>>
>>> thread.Start ();
>>> }
>>> }
>>>
>>> static void CheckSample (Data sample){
>>> if (sample.A != -sample.B || sample.A !=
>>> sample.C || sample.B != sample.D)
>>> throw new Exception (string.Format
>>> ("Invalid sample detected"));
>>> }
>>> }
>>> }
>>>
>>>
>>> --
>>> Yuriy Solodkyy
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>>
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
--
Yuriy Solodkyy
(y.solodkyy at gmail.com)
More information about the Mono-devel-list
mailing list