Skip to content

Commit

Permalink
[release/9.0] [wasm] Fixes for issue #108519 (#108650)
Browse files Browse the repository at this point in the history
* Fixes for issue 108519

* Fix build

---------

Co-authored-by: Katelyn Gadd <[email protected]>
Co-authored-by: Jeff Schwartz <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2024
1 parent e014d68 commit 24e3ac9
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 @@ -1589,6 +1589,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 @@ -1630,8 +1631,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 @@ -1641,8 +1643,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 24e3ac9

Please sign in to comment.