Use the psm crate to figure out the current stack pointer (#2358)

Currently the runtime needs to acquire the current stack pointer so it
can set a limit for where if the wasm stack goes below that point it
will abort the wasm code. Acquiring the stack pointer is done in a
brittle way right now which involves looking at the address of what we
hope is an on-stack structure. This turns out to not work at all with
ASan as well.

Instead this commit switches to the `psm` crate which is used by the
Rust compiler team for stack manipulation, namely a coarse version of
segmented stacks to avoid stack overflow in the compiler. We don't need
most of the implementation of `psm`, just the `stack_pointer` function,
but it shouldn't be a burden to bring in!

Closes #2344
This commit is contained in:
Alex Crichton
2020-11-05 07:29:04 -06:00
committed by GitHub
parent 6b137c2a3d
commit ea3306e74c
3 changed files with 23 additions and 3 deletions

10
Cargo.lock generated
View File

@@ -1397,6 +1397,15 @@ dependencies = [
"tempfile",
]
[[package]]
name = "psm"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96e0536f6528466dbbbbe6b986c34175a8d0ff25b794c4bacda22e068cd2f2c5"
dependencies = [
"cc",
]
[[package]]
name = "quick-error"
version = "1.2.3"
@@ -2572,6 +2581,7 @@ dependencies = [
"log",
"memoffset",
"more-asserts",
"psm",
"region",
"thiserror",
"wasmtime-environ",