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

kralu at poczta.onet.pl kralu at poczta.onet.pl
Mon Apr 4 09:47:26 EDT 2011

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, 

More information about the Mono-devel-list mailing list