Skip to content

Commit 9d02a18

Browse files
authored
Merge pull request #788 from Unity-Technologies/add-embedding-api-handler-block-guards
Add API to control behavior of thread abort within handler blocks (case 979679).
2 parents cb363d5 + f332f26 commit 9d02a18

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

mono/metadata/threads.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
#include <mono/utils/w32api.h>
5656
#include <mono/utils/mono-os-wait.h>
5757

58+
#include <mono/metadata/unity-utils.h>
59+
5860
#ifdef HAVE_SIGNAL_H
5961
#include <signal.h>
6062
#endif
@@ -4851,7 +4853,7 @@ async_abort_critical (MonoThreadInfo *info, gpointer ud)
48514853
gboolean protected_wrapper;
48524854
gboolean running_managed;
48534855

4854-
if (mono_get_eh_callbacks ()->mono_install_handler_block_guard (mono_thread_info_get_suspend_state (info)))
4856+
if (mono_unity_get_enable_handler_block_guards () && mono_get_eh_callbacks ()->mono_install_handler_block_guard (mono_thread_info_get_suspend_state (info)))
48554857
return MonoResumeThread;
48564858

48574859
/*someone is already interrupting it*/

mono/metadata/unity-utils.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,3 +1293,17 @@ mono_class_set_allow_gc_aware_layout(mono_bool allow)
12931293
{
12941294
mono_allow_gc_aware_layout = allow;
12951295
}
1296+
1297+
static mono_bool enable_handler_block_guards = TRUE;
1298+
1299+
void
1300+
mono_unity_set_enable_handler_block_guards (mono_bool allow)
1301+
{
1302+
enable_handler_block_guards = allow;
1303+
}
1304+
1305+
mono_bool
1306+
mono_unity_get_enable_handler_block_guards (void)
1307+
{
1308+
return enable_handler_block_guards;
1309+
}

mono/metadata/unity-utils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,10 @@ mono_method_get_method_definition(MonoMethod *method);
180180
void
181181
mono_class_set_allow_gc_aware_layout(mono_bool allow);
182182

183+
MONO_API void
184+
mono_unity_set_enable_handler_block_guards (mono_bool allow);
185+
186+
mono_bool
187+
mono_unity_get_enable_handler_block_guards (void);
188+
183189
#endif

0 commit comments

Comments
 (0)