Question: thread safety and correct usage of mono_gc_reference_queue_* APIs when embedding Mono (rare crash) #123853
Replies: 2 comments
-
|
From what I see, In my main thread, the call sequence is: Meanwhile, the GC finalizer created by Mono itself runs in another thread with the following calls: In ref_list_remove_element, there is also a comment mentioning an issue when the head changes concurrently: |
Beta Was this translation helpful? Give feedback.
-
|
I’d like to implement this mechanism myself using the weak ref API. Could you confirm if these three APIs are safe to call from my main thread?
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m embedding Mono and using the reference queue APIs to track when managed C# objects become unreachable so I can clean up associated native resources.
Specifically, I’m using:
mono_gc_reference_queue_new
mono_gc_reference_queue_add
mono_gc_reference_queue_free
I would like to know how to use these APIs when embedding Mono.
In my case, all three APIs are called directly from my main thread when needed and encounter below crash (rare).
thread_start
GC_start_routine
start_wrapper
start_wrapper_internal
finalizer_thread
reference_queue_process_all
malloc_report
malloc_vreport
malloc: *** error for object 0x600002ea4635:
pointer being freed was not allocated
Beta Was this translation helpful? Give feedback.
All reactions