Skip to content

Commit

Permalink
[interp] always require GC Unsafe mode in exception checkpoint (mono#…
Browse files Browse the repository at this point in the history
…17016)

[interp] always require GC Unsafe mode in exception checkpoint

Follow-up for mono#16955

/cc @BrzVlad
  • Loading branch information
lewurm authored and monojenkins committed Sep 26, 2019
1 parent 65dc4c3 commit c81b6f5
Showing 1 changed file with 11 additions and 4 deletions.
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

0 comments on commit c81b6f5

Please sign in to comment.