Skip to content

Commit

Permalink
Fix GC safety in mono_llvm_load_exceptions (). (#53318)
Browse files Browse the repository at this point in the history
  • Loading branch information
vargaz committed May 27, 2021
1 parent 44f050a commit 5dcc340
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mono/mono/mini/mini-exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3875,11 +3875,14 @@ mono_llvm_resume_exception (void)
MonoObject *
mono_llvm_load_exception (void)
{
HANDLE_FUNCTION_ENTER ();
ERROR_DECL (error);
MonoJitTlsData *jit_tls = mono_get_jit_tls ();

MonoJitTlsData *jit_tls = mono_get_jit_tls ();
MonoException *mono_ex = (MonoException*)mono_gchandle_get_target_internal (jit_tls->thrown_exc);

MONO_HANDLE_PIN (mono_ex);

MonoArray *ta = mono_ex->trace_ips;

if (ta) {
Expand Down Expand Up @@ -3915,7 +3918,7 @@ mono_llvm_load_exception (void)
mono_error_assert_ok (error);
}

return &mono_ex->object;
HANDLE_FUNCTION_RETURN_VAL (&mono_ex->object);
}

/*
Expand All @@ -3927,6 +3930,7 @@ void
mono_llvm_clear_exception (void)
{
MonoJitTlsData *jit_tls = mono_get_jit_tls ();

mono_gchandle_free_internal (jit_tls->thrown_exc);
jit_tls->thrown_exc = 0;
if (jit_tls->thrown_non_exc)
Expand Down

0 comments on commit 5dcc340

Please sign in to comment.