Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GC rooting during rehashing of iddict #52569

Merged
merged 2 commits into from
Dec 18, 2023
Merged
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
5 changes: 2 additions & 3 deletions src/iddict.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ JL_DLLEXPORT jl_genericmemory_t *jl_idtable_rehash(jl_genericmemory_t *a, size_t
size_t sz = a->length;
size_t i;
jl_value_t **ol = (jl_value_t **) a->ptr;
jl_genericmemory_t *newa = jl_alloc_memory_any(newsz);
jl_genericmemory_t *newa = NULL;
// keep the original memory in the original slot since we need `ol`
// to be valid in the loop below.
JL_GC_PUSH2(&newa, &a);
newa = jl_alloc_memory_any(newsz);
for (i = 0; i < sz; i += 2) {
if (ol[i + 1] != NULL) {
jl_table_assign_bp(&newa, ol[i], ol[i + 1]);
// it is however necessary here because allocation
// can (and will) occur in a recursive call inside table_lookup_bp
}
}
JL_GC_POP();
Expand Down