diff options
author | Alon Zakai <azakai@google.com> | 2020-12-14 14:15:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 14:15:36 -0800 |
commit | c1ab2b33f63d5e79143e05de4e8e9e0ddd970e77 (patch) | |
tree | c3f2e6bfe57b7c0f8cd6d17081ba721e0987d042 /test | |
parent | 814e897b4b177518a835a9ef30dd649312a77c78 (diff) | |
download | binaryen-c1ab2b33f63d5e79143e05de4e8e9e0ddd970e77.tar.gz binaryen-c1ab2b33f63d5e79143e05de4e8e9e0ddd970e77.tar.bz2 binaryen-c1ab2b33f63d5e79143e05de4e8e9e0ddd970e77.zip |
[StackCheck] Handle colliding names (#3390)
Add Names::getValidGlobalName calls to ensure we don't collide with an existing name.
Fixes emscripten-core/emscripten#12834
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/stack-check_enable-mutable-globals.txt | 22 | ||||
-rw-r--r-- | test/passes/stack-check_enable-mutable-globals.wast | 10 |
2 files changed, 32 insertions, 0 deletions
diff --git a/test/passes/stack-check_enable-mutable-globals.txt b/test/passes/stack-check_enable-mutable-globals.txt index c89f112a8..3f8aa4da7 100644 --- a/test/passes/stack-check_enable-mutable-globals.txt +++ b/test/passes/stack-check_enable-mutable-globals.txt @@ -39,3 +39,25 @@ ) ) ) +(module + (type $i32_i32_=>_none (func (param i32 i32))) + (type $none_=>_i32 (func (result i32))) + (import "env" "__stack_pointer" (global $sp (mut i32))) + (global $__stack_base (mut i32) (i32.const 0)) + (global $__stack_limit (mut i32) (i32.const 0)) + (global $__stack_base_0 (mut i32) (i32.const 0)) + (global $__stack_limit_0 (mut i32) (i32.const 0)) + (export "use_stack" (func $0)) + (export "__set_stack_limits" (func $__set_stack_limits)) + (func $0 (result i32) + (unreachable) + ) + (func $__set_stack_limits (param $0 i32) (param $1 i32) + (global.set $__stack_base_0 + (local.get $0) + ) + (global.set $__stack_limit_0 + (local.get $1) + ) + ) +) diff --git a/test/passes/stack-check_enable-mutable-globals.wast b/test/passes/stack-check_enable-mutable-globals.wast index 3028039fd..c3583cd2c 100644 --- a/test/passes/stack-check_enable-mutable-globals.wast +++ b/test/passes/stack-check_enable-mutable-globals.wast @@ -5,3 +5,13 @@ (global.get $sp) ) ) +;; if the global names are taken we should not crash +(module + (import "env" "__stack_pointer" (global $sp (mut i32))) + (global $__stack_base (mut i32) (i32.const 0)) + (global $__stack_limit (mut i32) (i32.const 0)) + (export "use_stack" (func $0)) + (func $0 (result i32) + (unreachable) + ) +) |