• Ben Smith's avatar
    [wasm] Fix crash serializing modules w/ big frames · fae1ab03
    Ben Smith authored
    When a wasm function has a large stack frame, the x64 code generator
    performs the stack overflow check before constructing the frame. This
    requires using the `address_of_real_stack_limit` external reference, as
    well as the `ThrowWasmStackOverflow` runtime function.
    
    `ThrowWasmStackOverflow` is called via a generated trampoline, but it is
    not a builtin, so the serializer adds it to the `stub_lookup_` map. This
    map is encoded by using a monotonically increasing `stub_id` that starts
    at 0.
    
    When the function is serialized, a stub is differentiated from a builtin
    by which half of the `i32` bits is used, upper or lower. A stub only
    uses the lower 16 bits and a builtin only uses the upper 16 bits.
    
    The deserializer checks whether the lower 16 bits are 0; if so, it is
    determined to be a builtin. But if the `stub_id` is 0, then it will be
    confused with builtin 0 (`RecordWrite`). Calling the builtin instead of
    the stub causes a crash.
    
    This CL starts all `stub_id`s at 1, which prevents the builtin/stub
    confusion.
    
    There is an additional bug that is not fixed by this CL:
    `ThrowWasmStackOverflow` shouldn't be called at all. Currently it is
    called because `address_of_real_stack_limit` is a thread-local value
    that is not properly relocated.
    
    Bug: chromium:808848
    Change-Id: I06b3e650ea58ad717dcc47a3716443e16582e711
    Reviewed-on: https://chromium-review.googlesource.com/981687Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Ben Smith <binji@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#52252}
    fae1ab03
Name
Last commit
Last update
..
baseline Loading commit data...
OWNERS Loading commit data...
compilation-manager.cc Loading commit data...
compilation-manager.h Loading commit data...
decoder.h Loading commit data...
function-body-decoder-impl.h Loading commit data...
function-body-decoder.cc Loading commit data...
function-body-decoder.h Loading commit data...
leb-helper.h Loading commit data...
local-decl-encoder.cc Loading commit data...
local-decl-encoder.h Loading commit data...
memory-tracing.cc Loading commit data...
memory-tracing.h Loading commit data...
module-compiler.cc Loading commit data...
module-compiler.h Loading commit data...
module-decoder.cc Loading commit data...
module-decoder.h Loading commit data...
signature-map.cc Loading commit data...
signature-map.h Loading commit data...
streaming-decoder.cc Loading commit data...
streaming-decoder.h Loading commit data...
wasm-code-manager.cc Loading commit data...
wasm-code-manager.h Loading commit data...
wasm-code-specialization.cc Loading commit data...
wasm-code-specialization.h Loading commit data...
wasm-constants.h Loading commit data...
wasm-debug.cc Loading commit data...
wasm-engine.cc Loading commit data...
wasm-engine.h Loading commit data...
wasm-external-refs.cc Loading commit data...
wasm-external-refs.h Loading commit data...
wasm-interpreter.cc Loading commit data...
wasm-interpreter.h Loading commit data...
wasm-js.cc Loading commit data...
wasm-js.h Loading commit data...
wasm-limits.h Loading commit data...
wasm-memory.cc Loading commit data...
wasm-memory.h Loading commit data...
wasm-module-builder.cc Loading commit data...
wasm-module-builder.h Loading commit data...
wasm-module.cc Loading commit data...
wasm-module.h Loading commit data...
wasm-objects-inl.h Loading commit data...
wasm-objects.cc Loading commit data...
wasm-objects.h Loading commit data...
wasm-opcodes.cc Loading commit data...
wasm-opcodes.h Loading commit data...
wasm-result.cc Loading commit data...
wasm-result.h Loading commit data...
wasm-serialization.cc Loading commit data...
wasm-serialization.h Loading commit data...
wasm-text.cc Loading commit data...
wasm-text.h Loading commit data...
wasm-value.h Loading commit data...