You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Interpreter] localloc does not guarantee platform stack alignment #125657
FrameDataAllocator::Alloc() in src/coreclr/vm/interpframeallocator.cpp aligns localloc buffer sizes to sizeof(void*) (4 bytes on WASM, 8 bytes on 64-bit platforms):
size = ALIGN_UP(size, sizeof(void*));
The JIT guarantees localloc returns pointers aligned to STACK_ALIGN (16 bytes on most platforms including WASM — see src/coreclr/jit/targetwasm.h), but the interpreter does not honor this. The fragment backing memory comes from raw malloc() with no explicit alignment, and subsequent bump allocations within a fragment are only pointer-size aligned.
This causes the ShowLocallocAlignment regression test to fail on WASM (and would fail on any platform using the interpreter) because stackalloc returns 8-byte aligned addresses instead of the expected 16-byte alignment.
Repro
Run JIT/Regression/Dev11/External/dev11_239804/ShowLocallocAlignment on a platform using the CoreCLR interpreter (e.g. WASM).
Expected
Localloc returns a 16-byte aligned pointer (matching STACK_ALIGN).
Actual
Localloc returns a pointer aligned only to sizeof(void*).
Suggested fix
Change the alignment in FrameDataAllocator::Alloc() to use INTERP_STACK_ALIGNMENT (16) instead of sizeof(void*), and ensure the returned pointer (not just the size) is aligned.
Activity
dotnet-policy-service commentedon Mar 17, 2026
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.
radekdoulik commentedon Mar 17, 2026
@janvorli @BrzVlad should we align FrameDataAllocator::Alloc() to INTERP_STACK_ALIGNMENT?
BrzVlad commentedon Mar 18, 2026
Sounds good. We could use AlignedAllocate here as well.
[Interpreter] Fix localloc to guarantee 16-byte stack alignment (dotn…
[Interpreter] Fix localloc to guarantee 16-byte stack alignment (dotn…
[Interpreter] Fix localloc to guarantee 16-byte stack alignment (#125720