Skip to content

Commit 7341098

Browse files
authored
Fix jl_set_precompile_field_replace for 0-size fields (#58155)
1 parent 5c869cd commit 7341098

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/staticdata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ static void jl_write_values(jl_serializer_state *s) JL_GC_DISABLED
17671767
tot = offset;
17681768
size_t fsz = jl_field_size(t, i);
17691769
jl_value_t *replace = (jl_value_t*)ptrhash_get(&bits_replace, (void*)slot);
1770-
if (replace != HT_NOTFOUND) {
1770+
if (replace != HT_NOTFOUND && fsz > 0) {
17711771
assert(t->name->mutabl && !jl_field_isptr(t, i));
17721772
jl_value_t *rty = jl_typeof(replace);
17731773
size_t sz = jl_datatype_size(rty);
@@ -2961,7 +2961,7 @@ static void jl_save_system_image_to_stream(ios_t *f, jl_array_t *mod_array,
29612961
if (jl_field_isptr(st, field)) {
29622962
record_field_change((jl_value_t**)fldaddr, newval);
29632963
}
2964-
else {
2964+
else if (jl_field_size(st, field) > 0) {
29652965
// replace the bits
29662966
ptrhash_put(&bits_replace, (void*)fldaddr, newval);
29672967
// and any pointers inside

test/precompile.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ precompile_test_harness(false) do dir
105105
process_state_calls = 0
106106
@assert process_state() === process_state()
107107
@assert process_state_calls === 0
108+
109+
const empty_state = Base.OncePerProcess{Nothing}() do
110+
return nothing
111+
end
112+
@assert empty_state() === nothing
108113
end
109114
""")
110115
write(Foo2_file,

0 commit comments

Comments
 (0)