Skip to content

Commit f49873c

Browse files
authored
[Mono]: Fix stackwalk callbacks calling mono_jit_info_get_method in async signal safe mode. (#123346)
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).
1 parent 868eaef commit f49873c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/mono/mono/metadata/threads.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3043,7 +3043,7 @@ dump_thread (MonoInternalThread *thread, ThreadDumpUserData *ud, FILE* output_fi
30433043
MonoStackFrameInfo *frame = &ud->frames [i];
30443044
MonoMethod *method = NULL;
30453045

3046-
if (frame->type == FRAME_TYPE_MANAGED)
3046+
if (frame->type == FRAME_TYPE_MANAGED && frame->ji && !frame->ji->async)
30473047
method = mono_jit_info_get_method (frame->ji);
30483048

30493049
if (method) {

src/mono/mono/mini/mini-exceptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ mono_find_jit_info (MonoJitTlsData *jit_tls, MonoJitInfo *res, MonoJitInfo *prev
598598
if (ji == (gpointer)-1)
599599
return ji;
600600

601-
if (ji && !ji->is_trampoline)
601+
if (ji && !ji->is_trampoline && !ji->async)
602602
method = jinfo_get_method (ji);
603603

604604
if (managed2 || (method && method->wrapper_type)) {
@@ -2909,7 +2909,7 @@ print_stack_frame_signal_safe (StackFrameInfo *frame, MonoContext *ctx, gpointer
29092909
{
29102910
MonoMethod *method = NULL;
29112911

2912-
if (frame->ji && frame->type != FRAME_TYPE_TRAMPOLINE)
2912+
if (frame->ji && frame->type != FRAME_TYPE_TRAMPOLINE && !frame->ji->async)
29132913
method = jinfo_get_method (frame->ji);
29142914

29152915
if (method) {

0 commit comments

Comments
 (0)