[runtime] Fixed use-after-free in context freeing
We had a use-after-free bug in context freeing that creating and freeing AppDomains in parallel exposed.
We called g_hash_table_remove in a callback to g_hash_table_foreach,
which
resulted in freeing the Slot struct that the g_hash_table_foreach was
holding a local reference to.
When it tried to get the chained 'next' element in the table, if
other threads caused enough memory pressure to reuse that memory
between freeing and getting the 'next' pointer, then we try to
dereference a garbage value and get a SIGSEGV.