[Mono-bugs] [Bug 463323] Bug with delegates to dynamic methods

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Jan 31 10:58:22 EST 2009


User jan.oravec at 6com.sk added comment

--- Comment #9 from Jan Oravec <jan.oravec at 6com.sk>  2009-01-31 08:58:18 MST ---
Created an attachment (id=269080)
 --> (https://bugzilla.novell.com/attachment.cgi?id=269080)
Prevent caching of invoke wrappers by pointer to dynamic method.

I have tracked down the bug.

The problem was, that invoke wrappers are cached by both pointers to methods
(first cache) and method signatures (second cache).

When dynamic method is freed, the entry in first cache is still present. If
another dynamic method with different signature is created on same memory
location later, it takes incorrect wrapper from the cache.

My patch fixes this by ignoring first cache if method is dynamic.

Btw. I think that first cache is pointless as it is implemented now:

1. Assume N methods with same signature.
2. When processing method 1, we have miss in both caches, the wrapper is built
and cached in both caches.
3. When processing method 1 again, we have cache hit on first cache.
4. When processing other method, we have cache hit on second cache, but we
never add entry to the first cache.

So, the first cache (by method pointer) is ralely used to speed up lookup and
it actually speed it down. I would suggest either adding entry into first cache
when we hit second cache.

Another possible fix is to actually cache wrapper inside MonoMethod and do not
use first cache at all. This should be faster and also prevent the original

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list