Skip to content

Commit 8a04df0

Browse files
ZentrikKristofferC
authored andcommitted
Fix GC rooting during rehashing of iddict (#52569)
Should fix #52558. `a` should be rooted before the alloc call. I removed the comment as it seemed to refer to a write barrier that was removed long ago. (cherry picked from commit 5977cb0)
1 parent f371de8 commit 8a04df0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/iddict.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ JL_DLLEXPORT jl_array_t *jl_idtable_rehash(jl_array_t *a, size_t newsz)
1515
size_t sz = jl_array_len(a);
1616
size_t i;
1717
jl_value_t **ol = (jl_value_t **)a->data;
18-
jl_array_t *newa = jl_alloc_vec_any(newsz);
18+
jl_array_t *newa = NULL;
1919
// keep the original array in the original slot since we need `ol`
2020
// to be valid in the loop below.
2121
JL_GC_PUSH2(&newa, &a);
22+
newa = jl_alloc_vec_any(newsz);
2223
for (i = 0; i < sz; i += 2) {
2324
if (ol[i + 1] != NULL) {
2425
jl_table_assign_bp(&newa, ol[i], ol[i + 1]);
25-
// it is however necessary here because allocation
26-
// can (and will) occur in a recursive call inside table_lookup_bp
2726
}
2827
}
2928
JL_GC_POP();

0 commit comments

Comments
 (0)