From 8d2987ff3a6f5da88c1de22fe399231c7b90494c Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 26 Sep 2021 15:55:30 -0700 Subject: [PATCH] Fix atomicfields serialization for system image (#42390) --- src/staticdata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/staticdata.c b/src/staticdata.c index d9218024551574..537abd77aa669d 100644 --- a/src/staticdata.c +++ b/src/staticdata.c @@ -1041,14 +1041,14 @@ static void jl_write_values(jl_serializer_state *s) jl_typename_t *tn = (jl_typename_t*)v; jl_typename_t *newtn = (jl_typename_t*)&s->s->buf[reloc_offset]; if (tn->atomicfields != NULL) { - size_t nf = jl_svec_len(tn->names); + size_t nb = (jl_svec_len(tn->names) + 31) / 32 * sizeof(uint32_t); uintptr_t layout = LLT_ALIGN(ios_pos(s->const_data), sizeof(void*)); write_padding(s->const_data, layout - ios_pos(s->const_data)); // realign stream newtn->atomicfields = NULL; // relocation offset layout /= sizeof(void*); arraylist_push(&s->relocs_list, (void*)(reloc_offset + offsetof(jl_typename_t, atomicfields))); // relocation location arraylist_push(&s->relocs_list, (void*)(((uintptr_t)ConstDataRef << RELOC_TAG_OFFSET) + layout)); // relocation target - ios_write(s->const_data, (char*)tn->atomicfields, nf); + ios_write(s->const_data, (char*)tn->atomicfields, nb); } } else if (((jl_datatype_t*)(jl_typeof(v)))->name == jl_idtable_typename) {