-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix AV in host from tracing on exit #77425
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
Conversation
|
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue DetailsFix #75760 For tracing, we had a static for the mutex which has a destructor. If a thread calls exit, the static destructor was called on that thread with no synchronization with other threads, resulting in potential issues where they would try to use the destructed object. This change just stores the pointer instead. It does have the following effects:
Related:
|
|
On a side, note, I really do not understand why you didnt check for g_trace_file != nullptr in trace::flush() before you even lock. |
|
Avoiding the lock at the end when it is not needed is definitely reasonable - and an improvement I will look at. However, the underlying root cause for the issue is the static object with a destructor, so that is what I wish to fix here. |
|
/backport to release/6.0-staging |
|
Started backporting to release/6.0-staging: https://github.com/dotnet/runtime/actions/runs/8744005173 |
Fix #75760
For tracing, we had a static for the mutex which has a destructor. If a thread calls exit, the static destructor was called on that thread with no synchronization with other threads, resulting in potential issues where they would try to use the destructed object.
This change switches to using a spin lock. In the majority of cases (running an application, tracing not enabled, no errors) we won't use it at all. When we do (tracing explicitly enabled, errors, commands for printing info), we don't expect much contention, since most hosting is on a single thread.
Related: