Skip to content

Commit

Permalink
[wasm] Fixes for issue dotnet#108519 (dotnet#108543)
Browse files Browse the repository at this point in the history
* Fixes for issue 108519
  • Loading branch information
kg authored and sirntar committed Oct 8, 2024
1 parent c69db4a commit 247142b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/mono/mono/mini/interp/jiterpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,7 @@ static void
free_queue (void *ptr) {
mono_os_mutex_lock (&queue_mutex);
// WARNING: Ensure we do not call into the runtime or JS while holding this mutex!
g_assert (shared_queues);
g_ptr_array_remove_fast (shared_queues, ptr);
g_ptr_array_free ((GPtrArray *)ptr, TRUE);
mono_os_mutex_unlock (&queue_mutex);
Expand Down Expand Up @@ -1645,8 +1646,9 @@ get_queue (int queue) {
GPtrArray *result = NULL;
if ((result = (GPtrArray *)mono_native_tls_get_value (key)) == NULL) {
g_assert (mono_native_tls_set_value (key, result = g_ptr_array_new ()));
mono_os_mutex_lock (&queue_mutex);
// WARNING: Ensure we do not call into the runtime or JS while holding this mutex!
mono_os_mutex_lock (&queue_mutex);
g_assert (shared_queues);
g_ptr_array_add (shared_queues, result);
mono_os_mutex_unlock (&queue_mutex);
}
Expand All @@ -1656,8 +1658,11 @@ get_queue (int queue) {
// Purges this item from all queues
void
mono_jiterp_tlqueue_purge_all (gpointer item) {
mono_os_mutex_lock (&queue_mutex);
// HACK: Call get_queue_key to ensure the queues are initialized before enumerating them
get_queue_key (0);

// WARNING: Ensure we do not call into the runtime or JS while holding this mutex!
mono_os_mutex_lock (&queue_mutex);
for (int i = 0; i < shared_queues->len; i++) {
GPtrArray *queue = (GPtrArray *)g_ptr_array_index (shared_queues, i);
gboolean ok = g_ptr_array_remove_fast (queue, item);
Expand Down

0 comments on commit 247142b

Please sign in to comment.