Skip to content
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

[interp] always require GC Unsafe mode in exception checkpoint #17016

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,15 @@ interp_throw (ThreadContext *context, MonoException *ex, InterpFrame *frame, con
} \
} while (0)

/* Don't throw exception if thread is in GC Safe mode. Should only happen in managed-to-native wrapper. */
#define EXCEPTION_CHECKPOINT_GC_UNSAFE \
do { \
if (mono_thread_interruption_request_flag && !mono_threads_is_critical_method (frame->imethod->method) && mono_thread_is_gc_unsafe_mode ()) { \
MonoException *exc = mono_thread_interruption_checkpoint (); \
if (exc) \
THROW_EX (exc, ip); \
} \
} while (0)

#define EXCEPTION_CHECKPOINT_IN_HELPER_FUNCTION \
do { \
Expand Down Expand Up @@ -3484,8 +3493,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
frame->ip = ip;

sp = do_icall_wrapper (frame, csignature, opcode, sp, target_ip, save_last_error);
if (mono_thread_is_gc_unsafe_mode ()) /* do not enter EH in GC Safe state */
EXCEPTION_CHECKPOINT;
EXCEPTION_CHECKPOINT_GC_UNSAFE;
CHECK_RESUME_STATE (context);
ip += 4;
MINT_IN_BREAK;
Expand Down Expand Up @@ -5928,8 +5936,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
MINT_IN_CASE(MINT_ICALL_PPPPPP_P)
frame->ip = ip;
sp = do_icall_wrapper (frame, NULL, *ip, sp, frame->imethod->data_items [ip [1]], FALSE);
if (mono_thread_is_gc_unsafe_mode ()) /* do not enter EH in GC Safe state */
EXCEPTION_CHECKPOINT;
EXCEPTION_CHECKPOINT_GC_UNSAFE;
CHECK_RESUME_STATE (context);
ip += 2;
MINT_IN_BREAK;
Expand Down