ves_icall_System_Threading_Interlocked_Exchange_T (MonoObject **location, MonoObject *value)
{
MonoObject *res;
+ MONO_CHECK_NULL (location, NULL);
res = (MonoObject *)InterlockedExchangePointer ((volatile gpointer *)location, value);
mono_gc_wbarrier_generic_nostore (location);
return res;
MonoJitInfo *ji = NULL;
if (!info)
return NULL;
+
+ /*
+ * The suspended thread might be holding runtime locks. Make sure we don't try taking
+ * any runtime locks while unwinding. In coop case we shouldn't safepoint in regions
+ * where we hold runtime locks.
+ */
+ if (!mono_threads_is_coop_enabled ())
+ mono_thread_info_set_is_async_context (TRUE);
mono_get_eh_callbacks ()->mono_walk_stack_with_state (last_managed, mono_thread_info_get_suspend_state (info), MONO_UNWIND_SIGNAL_SAFE, &ji);
+ if (!mono_threads_is_coop_enabled ())
+ mono_thread_info_set_is_async_context (FALSE);
return ji;
}