-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Profiling API: Different ClassID in ClassLoad and ClassUnload callbacks #13249
Comments
@davmason @dotnet/dotnet-diag |
Hi @NitzanEgozy, I did a first level of investigation, but I don't have a proposed fix yet. There are two separate issues here causing the strangeness you're seeing. There are three separate types involved and each callback is only giving you two (but a different set of two).
For This means you The issue is that we do a different set of filtering for This second part is where I suspect the fix will go. I think we will have to make the |
@janvorli do you know why there is special logic to skip calling |
Closing as by design |
What do you mean "by design"? In your previous comment, you detailed the bug and where you think the fix should take place. |
Sorry for the delay, I was out for a couple weeks on vacation. "By design" isn't the best phrasing. The issue is that this involves a bunch of really low level code that hasn't changed in forever, so fixing carries some real risk that we could break something unrelated. There is a relatively simple workaround available - instead of relying on the class unload callback, you can rely on the module unload callback and unload all classes from that module. We do that in the profiler tests here: runtime/src/tests/profiler/native/getappdomainstaticaddress/getappdomainstaticaddress.cpp Lines 150 to 246 in 9f92311
Since there is a workaround and the fix has risk, this bug is unlikely to get fixed. |
Hey all,
this is a followup of a bug we encountered in all .Net frameworks version, which was un-reproducible until recently (.Net Core < 3 didn't support class unloading).
First, I'll link to the original posts (SO and msdn forums): https://stackoverflow.com/questions/54883986/icorprofilercallbackclassunloadstarted-not-called-for-a-generic-class-even-th https://social.msdn.microsoft.com/Forums/vstudio/en-US/06f3022d-0d6e-450c-8100-9e082fb21ee1/icorprofilercallbackclassunloadstarted-not-called-for-a-generic-class-instantiation-even-though?forum=clr
We further analyzed it back then and noticed we get a different ClassID on load then we get on Unload.
I managed to reproduce in on latest .net core preview (3.0.100-preview7-012821) on Windows 10. You can find it here: https://github.com/NitzanEgozy/dotnet/tree/master/testers/Unloading (cd out, run.bat)
The important part of the output:
As we can see, Plugin.MyGenList1 is loaded twice and unloaded twice. The load/unload for System.__Canon is fine (same ClassID). We have another Load/Unload set. The Load is for System.String, but the the unload is unknown (Can't retrieve moduleID, probably too late). They are of different ClassIDs. Also, the loaded ClassID (Plugin.MyGenList1 <System.String> (140731382880344)) is never unloaded, and the unloaded ClassID (Plugin.MyGenList1 (140731382879688)) is never loaded, nor do we get this ClassID in any other way.
This is a huge issue for profilers who rely on tracking currently loaded classes.
The text was updated successfully, but these errors were encountered: