Skip to content

Commit

Permalink
fix off-by-one in gc_page_free
Browse files Browse the repository at this point in the history
fix #21470
  • Loading branch information
vtjnash committed Apr 22, 2017
1 parent 5444473 commit b26d120
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/gc-pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,14 @@ void jl_gc_free_page(void *p)
// ensure so we don't release more memory than intended
size_t n_pages = jl_page_size / GC_PAGE_SZ; // exact division
decommit_size = jl_page_size;
p = (void*)((uintptr_t)p & ~(jl_page_size - 1)); // round down to the nearest physical page
void *otherp = (void*)((uintptr_t)p & ~(jl_page_size - 1)); // round down to the nearest physical page
p = otherp;
while (n_pages--) {
struct jl_gc_metadata_ext info = page_metadata_ext(p);
struct jl_gc_metadata_ext info = page_metadata_ext(otherp);
msk = (uint32_t)(1 << info.pagetable0_i);
if (info.pagetable0->allocmap[info.pagetable0_i32] & msk)
goto no_decommit;
p = (void*)((char*)p + GC_PAGE_SZ);
otherp = (void*)((char*)otherp + GC_PAGE_SZ);
}
}
#ifdef _OS_WINDOWS_
Expand Down

0 comments on commit b26d120

Please sign in to comment.