In src/objects.c, around line 82, the function find_vtable_meth_ns() creates a
Key PMC to perform a lookup:
PMC * const key = VTABLE_nextkey_keyed(interp, key_new(interp), ns,
ITERATE_FROM_START);
If a GC run happens in the rest of this function, it could collect the newly
created Key -- PMCs created and held outside of structures visible to GC are
vulnerable to collection.
Unfortunately, I can't reproduce the problem on Linux on x86. However, I do
think that storing the key temporarily in a place where it will get marked
appropriately may fix things. Note that unpinning the key is important at
all exit points.
I hope this patch improves things for Windows users -- or at least stops them
from getting worse.
-- c
=== src/objects.c
==================================================================
--- src/objects.c (revision 3990)
+++ src/objects.c (local)
@@ -90,6 +90,8 @@
int j;
+ dod_register_pmc(interp, key);
+
for (j = 0; j < k; ++j) {
STRING * const ns_key = (STRING *)parrot_hash_get_idx(interp,
(Hash *)PMC_struct_val(ns), key);
@@ -99,9 +101,13 @@
if (res->vtable->base_type == enum_class_Sub &&
(PMC_sub(res)->vtable_index == vtable_index ||
string_compare(interp, meth_str, ns_key) == 0))
+ {
+ dod_unregister_pmc(interp, key);
return res;
+ }
}
+ dod_unregister_pmc(interp, key);
return PMCNULL;
}