mirror of
https://github.com/janet-lang/janet
synced 2026-11-28 18:03:09 +00:00
Apply fix for #1888 from Paolo Marrone
Just mark janet_vm.top_dyns during mark phase of collection. It was skipped as it is not part of the usual interpreter flow and was missed in testing. Also add a test case for it.
This commit is contained in:
2 files changed
+11
No files matched your search
@@ -79,5 +79,13 @@ int system_test() {
|
||||
|
||||
assert(janet_equals(tuple1, tuple2));
|
||||
|
||||
/* System test for GC bug #1888 */
|
||||
JanetTable *env = janet_core_env(NULL);
|
||||
janet_setdyn("probe", janet_wrap_integer(42));
|
||||
assert(!janet_dostring(env, "(gccollect)", "gc", NULL));
|
||||
Janet value = janet_dyn("probe");
|
||||
assert(janet_checktype(value, JANET_NUMBER));
|
||||
assert(janet_unwrap_integer(value) == 42);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -592,6 +592,9 @@ void janet_collect(void) {
|
||||
#ifdef JANET_EV
|
||||
janet_ev_mark();
|
||||
#endif
|
||||
if (janet_vm.top_dyns) {
|
||||
janet_mark(janet_wrap_table(janet_vm.top_dyns));
|
||||
}
|
||||
if (janet_vm.root_fiber != NULL) { /* Can be NULL if janet_collect called outside of interpreter loop */
|
||||
janet_mark_fiber(janet_vm.root_fiber);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user