summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-12-14 14:15:36 -0800
committerGitHub <noreply@github.com>2020-12-14 14:15:36 -0800
commitc1ab2b33f63d5e79143e05de4e8e9e0ddd970e77 (patch)
treec3f2e6bfe57b7c0f8cd6d17081ba721e0987d042 /test
parent814e897b4b177518a835a9ef30dd649312a77c78 (diff)
downloadbinaryen-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.txt22
-rw-r--r--test/passes/stack-check_enable-mutable-globals.wast10
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)
+ )
+)