Skip to content

Commit 6e70552

Browse files
authored
Merge pull request #21491 from JuliaLang/jn/fix-gc-large-page
fix off-by-one in gc_page_free
2 parents 5e5ea53 + b26d120 commit 6e70552

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/gc-pages.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,14 @@ void jl_gc_free_page(void *p)
279279
// ensure so we don't release more memory than intended
280280
size_t n_pages = jl_page_size / GC_PAGE_SZ; // exact division
281281
decommit_size = jl_page_size;
282-
p = (void*)((uintptr_t)p & ~(jl_page_size - 1)); // round down to the nearest physical page
282+
void *otherp = (void*)((uintptr_t)p & ~(jl_page_size - 1)); // round down to the nearest physical page
283+
p = otherp;
283284
while (n_pages--) {
284-
struct jl_gc_metadata_ext info = page_metadata_ext(p);
285+
struct jl_gc_metadata_ext info = page_metadata_ext(otherp);
285286
msk = (uint32_t)(1 << info.pagetable0_i);
286287
if (info.pagetable0->allocmap[info.pagetable0_i32] & msk)
287288
goto no_decommit;
288-
p = (void*)((char*)p + GC_PAGE_SZ);
289+
otherp = (void*)((char*)otherp + GC_PAGE_SZ);
289290
}
290291
}
291292
#ifdef _OS_WINDOWS_

0 commit comments

Comments
 (0)