Skip to content

Commit 4f0fd2a

Browse files
committed
[mini] Align stack when resuming to catch handler
1 parent 3325bdf commit 4f0fd2a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mono/mini/mini-exceptions.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,11 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
22322232
#endif
22332233
} else {
22342234
MONO_CONTEXT_SET_IP (ctx, ei->handler_start);
2235+
/*
2236+
* When the exception is thrown in async fashion, we can have the stack pointer
2237+
* unaligned. Make sure we resume to the catch handler with an aligned stack.
2238+
*/
2239+
MONO_CONTEXT_SET_SP (ctx, (mgreg_t)MONO_CONTEXT_GET_SP (ctx) & ~(MONO_ARCH_FRAME_ALIGNMENT - 1));
22352240
}
22362241
mono_set_lmf (lmf);
22372242
#ifndef DISABLE_PERFCOUNTERS

0 commit comments

Comments
 (0)