Oh, I see. So it sounds like there is no clear way to unload the assembly and a DLL with it at all? Do you know if this the case with Win .NET?
I remember hearing that in Mono you can unload an assembly when unloading an appdomain. I'm not sure how that interacts with JITed functions. Also, vtfixup functions end up in the default appdomain, which I believe can only be unloaded at process exit.
I don't know if there's a way to do it earlier in native .NET.
I think it is a sort of nearly theoretical question because it would be really very hard to get this in practice. I think if to remove fixup->done it would totally OK as you say. But if not AFAIK it is possible that you get an older vtable value but newer fixup->done if threads are at distinct CPUs (strong enough "fence" is required to guarantee memory access order).
Ah, I think you're right. That seems like a good argument for getting rid of fixup->done.
BTW I submitted bug report with my test case and patch to mono: https://bugzilla.xamarin.com/show_bug.cgi?id=37913
Thanks.