[Mono-dev] StackOverflow on System.Delegate.Equals

Alan alan.mcgovern at gmail.com
Mon Apr 4 15:48:55 EDT 2011


Aren't event handler methods emitted with a [synchronized] attribute by
default which would prevent this issue? You can check by disassembling the
IL and seeing if its there.

Alan

On 4 Apr 2011 14:55, <kralu at poczta.onet.pl> wrote:
> W dniu 2011-03-30 22:07:45 użytkownik Miguel de Icaza <miguel at novell.com>
napisał:
>
>> While another one is doing an equality test, the state is half-built.
>> The way you could instrument this is to rewrite that routine to not be
>> recursive, but instead to be iterative, and have a maximum count,
>> something like:
>>
>> MulticastDelegate track_this = this;
>> MulticastDelegate track_other = d;
>>
>> for (int i = 0; i < 10000; i++){
>> object this_prev = track_this.prev;
>> object other_prev = d.prev;
>>
>> if (this_prev != other_prev)
>> return false;
>> }
>> if (i == 10000)
>> Console.WriteLine ("The corrupted instance is {0}", this.GetType ());
>>
>> return true;
>
> Thanks for your reply. I'm not sure but it seems that your snippet will
put a text on a screen always when the delegates are equal. Anyway, I've
rewrote that routine as you suggested and here's the result:
http://monobin.com/__mb1963e9
>
> I've also just added a lines like below to the end of original equals
method.
>
> if (this == this.prev)
> Console.WriteLine ("The corrupted instance is {0}", this.GetType ());
> return this.prev.Equals(d.prev);
>
> ...and I'm waiting for a crush.
> I'd appreciate any other hints or advices. Thanks in advance.
> Best regards,
> Marcin
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110404/8bd04d9a/attachment.html 


More information about the Mono-devel-list mailing list