Skip to content

Commit 90934ff

Browse files
authored
Initialize padding in datatype layout (#47640)
We use that memory for hashing it, so we need to ensure it is set to zero.
1 parent 185b583 commit 90934ff

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/datatype.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ static jl_datatype_layout_t *jl_get_layout(uint32_t sz,
219219
flddesc->alignment = alignment;
220220
flddesc->haspadding = haspadding;
221221
flddesc->fielddesc_type = fielddesc_type;
222+
flddesc->padding = 0;
222223
flddesc->npointers = npointers;
223224
flddesc->first_ptr = (npointers > 0 ? pointers[0] : -1);
224225

@@ -815,6 +816,7 @@ JL_DLLEXPORT jl_datatype_t * jl_new_foreign_type(jl_sym_t *name,
815816
layout->haspadding = 1;
816817
layout->npointers = haspointers;
817818
layout->fielddesc_type = 3;
819+
layout->padding = 0;
818820
jl_fielddescdyn_t * desc =
819821
(jl_fielddescdyn_t *) ((char *)layout + sizeof(*layout));
820822
desc->markfunc = markfunc;

src/julia.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ typedef struct {
523523
uint16_t alignment; // strictest alignment over all fields
524524
uint16_t haspadding : 1; // has internal undefined bytes
525525
uint16_t fielddesc_type : 2; // 0 -> 8, 1 -> 16, 2 -> 32, 3 -> foreign type
526+
uint16_t padding : 13;
526527
// union {
527528
// jl_fielddesc8_t field8[nfields];
528529
// jl_fielddesc16_t field16[nfields];

0 commit comments

Comments
 (0)