-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Avalonia calling into the runtime after shut down #90079
Comments
Tagging subscribers to this area: @tommcdon Issue Details
Stack traces: Repro on macOS:
Happens with .NET 6 and .NET 7, didn't test it on newer runtime.
|
cc @AndyAyersMS |
Thanks for opening an issue. |
@filipnavara Thanks for reporting the issue. Does this reproduce on ARM64 (M1/M2) or X64 macOS (or both)? |
Tested and reproduced on M1. The underlying mechanism of the deadlock doesn't seem platform specific though. |
@filipnavara thanks! |
I tried reproducing it with .NET 6 on Windows and wasn't able to, will continue once I have access to M1. |
I also tried reproducing it with .NET 7 on Mac x64, but wasn't able to because there was a NullReferenceException in the Avalonia code. |
Here is the stack of the avalonia app (was able to reproduce on M1)
|
After further investigation, we found that the Runtime was shut down and Avalonia is calling into the Runtime after it is shut down. This is unsupported behavior, so we have opened an issue in Avalonia here. We will close this issue. We know the Runtime is shut down because
The frame without a symbol is MicroCom.Runtime.MicroComVtblBase.Release(MicroCom.Runtime.Ccw*). |
That's not correct. This is expected to work and not hang. We have fixed number of similar bugs. For example #100293 was fixing a very similar hang/crash where some networking code was calling into the runtime after the shutdown. Runtime shutdown is not really a thing. We are really only notifying the diagnostic stack about the shutdown. However, the runtime is expected to work until the OS physically kills the process and the diagnostic stack is expected to stay out of the way once it was notified about shutdown. It is fine for the debugger experience to be degraded after the diagnostic stack was notified about the shutdown. However, it is not expected to hang. |
I agree that Avalonia may want to avoid calling into the runtime during shutdown. Minimizing work done during shutdown is general goodness. But it is not changing the fact that we have a bug in the runtime shutdown logic. |
This issue no longer repros when using Avalonia 11.0.11. |
Well, yeah, because Avalonia fixed the issue that triggered it... which still doesn't fix the debugger/runtime behavior even if the Avalonia users are unblocked. |
@jkotas Since Avalonia has already fixed the issue, shall we close this issue? |
I am fine with deprioritizing any work on this, but it's NOT fixed. The deadlock can still be triggered with the latest runtime. It just happened that Avalonia 11.0.0 was a high profile library that triggered it, and that particular version continues to trigger it today. The same problem can be triggered by other code, and I have seen it happening. This was just convenient way to reproduce it. |
I agree with @filipnavara. This bug is not fixed. We were lucky that the Avalonia repro was reliable enough to get to the bottom of it. The most likely manifestation of this bug is intermittent hang at the end of debugging session. My guess is that it is hit intermittently by quite a few users out there in number of workloads that we just do not know about. |
Stack traces:
Sample of Avalonia Application.txt
Repro on macOS:
Happens with .NET 6 and .NET 7, didn't test it on newer runtime.
The text was updated successfully, but these errors were encountered: