Skip to content

Commit

Permalink
Fix GC not following module parents
Browse files Browse the repository at this point in the history
Also a missing root for new modules. Thanks to @yuyiacho for finding
those issues. Fix #11395.
  • Loading branch information
carnaval committed May 22, 2015
1 parent 9e8badc commit e8521fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,9 @@ NOINLINE static int gc_mark_module(jl_module_t *m, int d)
verify_parent1("module", m, &m->constant_table, "constant_table");
refyoung |= gc_push_root(m->constant_table, d);
}

refyoung |= gc_push_root(m->parent, d);

return refyoung;
}

Expand Down
2 changes: 2 additions & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ jl_module_t *jl_new_module(jl_sym_t *name)
DLLEXPORT jl_value_t *jl_f_new_module(jl_sym_t *name, uint8_t std_imports)
{
jl_module_t *m = jl_new_module(name);
JL_GC_PUSH1(&m);
m->parent = jl_main_module;
gc_wb(m, m->parent);
if (std_imports) jl_add_standard_imports(m);
JL_GC_POP();
return (jl_value_t*)m;
}

Expand Down
3 changes: 1 addition & 2 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ jl_value_t *jl_eval_module_expr(jl_expr_t *ex)
jl_module_t *newm = jl_new_module(name);
newm->parent = parent_module;
b->value = (jl_value_t*)newm;

gc_wb(parent_module, newm);
gc_wb_binding(b, newm);

if (parent_module == jl_main_module && name == jl_symbol("Base")) {
// pick up Base module during bootstrap
Expand Down

0 comments on commit e8521fc

Please sign in to comment.