Hi Yuriy,<div><br></div><div>With how many cores and on what CPU did managed to reproduce this?</div><div>I'm running this on my 4 cores nehalem mac without any luck. I'll diff ConcurrentStack</div><div>between 2.8 and 2.10 to see what could be.</div>
<div><div><br><div class="gmail_quote">On Sun, Jul 22, 2012 at 5:10 AM, Yuriy Solodkyy <span dir="ltr"><<a href="mailto:yuriy@couldbedone.com" target="_blank">yuriy@couldbedone.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
It looks like the ConcurrentStack does not work with big enough<br>
structures anymore.  12 bytes struct is enough to reproduce the<br>
problem occasionally, 16 bytes structure to reproduce it immediately.<br>
It worked fine in mono 2.8.  The following code shows that we may pop<br>
inconsistent structure from the stack from time to time.<br>
<br>
using System;<br>
using System.Collections.Concurrent;<br>
namespace CocurrentTest {<br>
        class MainClass {<br>
                struct Data {<br>
                        public int A; public int B; public int C; public int D;<br>
                        public Data(int v) {<br>
                                A = v; B = -v; C = v; D = -v;<br>
                        }<br>
                }<br>
<br>
                public static void Main (string[] args) {<br>
                        Console.WriteLine ("Hello World!");<br>
                        var data = new byte[1024 * 1024];<br>
                        var stack = new ConcurrentStack<Data> ();<br>
<br>
                        for (var i = 0; i < 50; i++) {<br>
<br>
                                var thread = new System.Threading.Thread (v => {<br>
<br>
                                        var rnd = new Random ();<br>
                                        while (true) {<br>
                                                int pushCount = rnd.Next (50);<br>
                                                int popCount = rnd.Next (50);<br>
<br>
                                                for (var k = 0; k <<br>
pushCount; k++) {<br>
<br>
<br>
                                                        var sample =<br>
new Data (rnd.Next(Int32.MaxValue));<br>
                                                        CheckSample (sample);<br>
<br>
                                                        stack.Push (sample);<br>
                                                }<br>
<br>
                                                for (var k = 0; k <<br>
popCount; k++) {<br>
                                                        Data<br>
retrievedSample = new Data();<br>
                                                        if<br>
(stack.TryPop (out retrievedSample)) {<br>
<br>
CheckSample (retrievedSample);<br>
                                                        }<br>
                                                }<br>
                                        }<br>
                                }<br>
                                );<br>
<br>
                                thread.Start ();<br>
                        }<br>
                }<br>
<br>
                static void CheckSample (Data sample){<br>
                        if (sample.A != -sample.B || sample.A !=<br>
sample.C || sample.B != sample.D)<br>
                                throw new Exception (string.Format<br>
("Invalid sample detected"));<br>
                }<br>
        }<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Yuriy Solodkyy<br>
_______________________________________________<br>
Mono-devel-list mailing list<br>
<a href="mailto:Mono-devel-list@lists.ximian.com">Mono-devel-list@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-devel-list" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-devel-list</a><br>
</font></span></blockquote></div><br></div></div>