Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ static jl_module_t *jl_new_module__(jl_sym_t *name, jl_module_t *parent)
m->istopmod = 0;
m->uuid = uuid_zero;
static unsigned int mcounter; // simple counter backup, in case hrtime is not incrementing
m->build_id.lo = jl_hrtime() + (++mcounter);
// TODO: this is used for ir decompression and is liable to hash collisions so use more of the bits
m->build_id.lo = bitmix(jl_hrtime() + (++mcounter), jl_rand());
if (!m->build_id.lo)
m->build_id.lo++; // build id 0 is invalid
m->build_id.hi = ~(uint64_t)0;
Expand Down
6 changes: 5 additions & 1 deletion src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -4410,7 +4410,11 @@ static jl_value_t *jl_restore_package_image_from_stream(ios_t *f, jl_image_t *im
JL_SIGATOMIC_END();

// Add roots to methods
jl_copy_roots(method_roots_list, jl_worklist_key((jl_array_t*)restored));
int failed = jl_copy_roots(method_roots_list, jl_worklist_key((jl_array_t*)restored));
if (failed != 0) {
jl_printf(JL_STDERR, "Error copying roots to methods from Module: %s\n", pkgname);
abort();
}
// Insert method extensions and handle edges
int new_methods = jl_array_nrows(extext_methods) > 0;
if (!new_methods) {
Expand Down
16 changes: 15 additions & 1 deletion src/staticdata_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,17 +736,31 @@ static void jl_activate_methods(jl_array_t *external, jl_array_t *internal, size
}
}

static void jl_copy_roots(jl_array_t *method_roots_list, uint64_t key)
static int jl_copy_roots(jl_array_t *method_roots_list, uint64_t key)
{
size_t i, l = jl_array_nrows(method_roots_list);
int failed = 0;
for (i = 0; i < l; i+=2) {
jl_method_t *m = (jl_method_t*)jl_array_ptr_ref(method_roots_list, i);
jl_array_t *roots = (jl_array_t*)jl_array_ptr_ref(method_roots_list, i+1);
if (roots) {
assert(jl_is_array(roots));
if (m->root_blocks) {
// check for key collision
uint64_t *blocks = jl_array_data(m->root_blocks, uint64_t);
size_t nx2 = jl_array_nrows(m->root_blocks);
for (size_t i = 0; i < nx2; i+=2) {
if (blocks[i] == key) {
// found duplicate block
failed = -1;
}
}
}

jl_append_method_roots(m, key, roots);
}
}
return failed;
}

static jl_value_t *read_verify_mod_list(ios_t *s, jl_array_t *depmods)
Expand Down