Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WasmPageAllocator: fix bug not aligning allocations #5737

Merged
merged 1 commit into from Jun 28, 2020

Conversation

marler8997
Copy link
Contributor

@marler8997 marler8997 commented Jun 28, 2020

Implements aligned allocations in WasmPageAllocator.

My changes to arena allocator (#5736) exposed a bug in WasmPageAllocator when allocating a block aligned to 262144 bytes. Note that this appears to be an existing bug unrelated to the new allocator changes, but exposed by them. WasmPageAllocator was not aligning allocations, but its page size is 64K so the bug is unlikely to be triggered unless you are doing very highly aligned allocations.

Here is the stacktrace of the bug:

327/1431 heap.test "std-wasm32-wasi-Debug-bare-single ArenaAllocator"...reached unreachable codeError: failed to run main module `/home/vsts/work/1/s/zig-cache/o/dnpZookktBQLFN5oOKiztk1CZcNp2WOzT3Ma5Gzm6ogPHQ9uvB0dGKFtpYMroB59/test.wasm`

Caused by:
    0: failed to invoke `_start`
    1: wasm trap: unreachable, source location: @4f82
       wasm backtrace:
         0: <unknown>!os.abort
         1: <unknown>!builtin.default_panic
         2: <unknown>!debug.assert
         3: <unknown>!mem.ValidationAllocator(*mem.Allocator).alloc
         4: <unknown>!mem.Allocator.callAllocFn
         5: <unknown>!mem.Allocator.allocAdvanced.4426
         6: <unknown>!mem.Allocator.alignedAlloc.3219
         7: <unknown>!heap.testAllocatorLargeAlignment
         8: <unknown>!heap.test "std-wasm32-wasi-Debug-bare-single ArenaAllocator"
         9: <unknown>!std.special.main
         10: <unknown>!_start
       

Tests failed. Use the following command to reproduce the failure:

@marler8997 marler8997 marked this pull request as ready for review June 28, 2020 05:56
@andrewrk andrewrk merged commit 374e3e4 into ziglang:master Jun 28, 2020
@marler8997 marler8997 deleted the wasmAllocatorAlign branch June 28, 2020 19:49
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.

None yet

2 participants