-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[Mono]: Fix stackwalk callbacks calling mono_jit_info_get_method in async signal safe mode. #123346
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
[Mono]: Fix stackwalk callbacks calling mono_jit_info_get_method in async signal safe mode. #123346
Conversation
…sync signal safe mode. As part of dotnet@d34ef7e a number of additional stack walking scenarios that could run as async signal safe (called from signal handlers), was flag as being async, preventing loading of full MonoJitInfo. An AOT methods MonoJitInfo loaded when a thread runs in async signal safe mode can't be passed to mono_jit_info_get_method or it will trigger the following assert: Assertion jit-info.c:918 (!ji->async) There are some issues reporting this assert for .net10, like: dotnet#122797 After looking over the changes done in dotnet@d34ef7e it appears that two scenarios, get_thread_dump and mono_handle_native_crash could hit scenarios where it would call mono_jit_info_get_method using MonoJitInfo loaded under async signal safe mode. This PR fixes both these scenarios making sure they correctly check the async state of MonoJitInfo before calling mono_jit_info_get_method. For more details, dotnet#122797 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a crash in Mono's stack walking functionality when running in async signal safe mode. The issue occurs when mono_jit_info_get_method is called on a MonoJitInfo structure that was loaded during async signal safe operations (indicated by the async flag), which triggers an assertion failure.
Changes:
- Added
!ji->asyncchecks before callingjinfo_get_methodin two locations inmini-exceptions.c - Added
frame->ji && !frame->ji->asynccheck before callingmono_jit_info_get_methodinthreads.c
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/mono/mono/mini/mini-exceptions.c | Added async flag checks in mono_find_jit_info (line 601) and print_stack_frame_signal_safe (line 2912) to prevent calling jinfo_get_method on async-loaded JIT info |
| src/mono/mono/metadata/threads.c | Added async flag check in dump_thread (line 3046) to prevent calling mono_jit_info_get_method on async-loaded JIT info during thread dump collection |
|
WASM build issues are known issue, #123237. |
|
I initially assumed the assertion was happening during normal operation of the app. It would be great if this actually happened only when the app was already closing. This would need backport to .net10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
/backport to release/10.0 |
|
Started backporting to |
As part of d34ef7e a number of additional stack walking scenarios that could run as async signal safe (called from signal handlers), was flag as being async signal safe, prevents loading of full MonoJitInfo for AOT methods due to risk of deadlocks under async signal safe mode.
An AOT methods MonoJitInfo loaded when a thread runs in async signal safe mode can't be passed to mono_jit_info_get_method or it will trigger the following assert:
Assertion jit-info.c:918 (!ji->async)
There are some issues reporting this assert for .net10, like:
#122797
After looking over the changes done in d34ef7e it appears that two scenarios, get_thread_dump and mono_handle_native_crash could hit scenarios where it would call mono_jit_info_get_method using MonoJitInfo loaded under async signal safe mode.
This PR fixes both these scenarios making sure they correctly check the async state of MonoJitInfo before calling mono_jit_info_get_method.
For more details, #122797 (comment).