Bug 231917 - [bmalloc] Heap.shrinkLarge() allocates non-aligned region
Summary: [bmalloc] Heap.shrinkLarge() allocates non-aligned region
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: bmalloc (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-18 16:02 PDT by Basuke Suzuki
Modified: 2021-10-25 16:03 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Basuke Suzuki 2021-10-18 16:02:12 PDT
Because the newly allocated region is not aligned well, unaligned region will be returned to LargeFree while splitAndAllocate() is called. Those regions won't match to any request to LargeFree until the neighbor region is returned to LargeFree and get merged with that.

1. Align 40k memory region A. Both start and end is aligned in 4k boundary.
2. realloc A to 36k + 1. shrinkLarge tries to split it in that size, B (36k +1) and C (4k - 1)
3. B's end is not aligned, but there's no practical issue.
4. On the other hand, C's start address is not aligned and sit in the LargeFree. It won't fit to any request because it's not aligned.
Comment 1 Basuke Suzuki 2021-10-18 17:09:42 PDT
Above description was wrong. Rewrote.

Because the newly allocated region is not aligned well, unaligned region will be returned to LargeFree while splitAndAllocate() is called. Those regions won't match to any request to LargeFree until the neighbor region is returned to LargeFree and get merged with that.

1. Align 40k memory region A. Both start and end is aligned in 4k boundary.
2. realloc A to 36k + 8. shrinkLarge tries to split it in that size, B (36k +8) and C (4k - 8)
3. B's end is not aligned, but there's no practical issue.
4. On the other hand, C's start address is not aligned and sit in the LargeFree. It won't fit to any request because it's not aligned.
Comment 2 Radar WebKit Bug Importer 2021-10-25 16:03:18 PDT
<rdar://problem/84635991>