Skip to content

fix alignment of guard blocks#4137

Merged
dnovillo merged 2 commits intoKhronosGroup:mainfrom
jamesdolan:guard-block-alignment
Mar 20, 2026
Merged

fix alignment of guard blocks#4137
dnovillo merged 2 commits intoKhronosGroup:mainfrom
jamesdolan:guard-block-alignment

Conversation

@jamesdolan
Copy link
Copy Markdown
Contributor

@jamesdolan jamesdolan commented Dec 31, 2025

the GUARD_BLOCKS feature that is enabled when NDEBUG is not specified can cause unaligned memory allocations. This was causing Emscripten debug builds to throw alignment faults when -sSAFE_HEAP=2, and causing Safari to leak large amounts of memory when safe heap was disabled.

this change simply fixes the guard block size logic to ensure the combined header+guard size is 16-byte aligned which I believe was the intention.

Also, I realize the leak claim sounds crazy, and if true is clearly a safari bug, but fixing alignment issue is still a good idea. Also here is a simple repro.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 31, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Collaborator

@dnovillo dnovillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM.

I'll merge this after tests finish.

@dnovillo dnovillo merged commit 36ee985 into KhronosGroup:main Mar 20, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants