emscripten-core / emscripten-core/emscripten

Weird 'unreachable' trap instruction

Open
#18,469 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I encountered a weird 'unreachable' instruction in my app and crash each time run into the function after I upgrade EMSDK from 3.0.0 to 3.1.28. I think the 'unreachable' instruction should not be here as it's normal running path. (see follow digest blocks which contain the 'unreachable' instruction). The function was working fine before.

I test old version EMSDKs, seems the weird 'unreachable' instruction emerged since 3.1.15. Any ideas?

```
block $label1
block $label2
local.get $var3
i32.load offset=32
local.tee $var3
i32.eqz
if
local.get $var5
i32.eqz
br_if $label1
local.get $var4
i64.const 0
i64.store
i32.const 0
local.set $var3
br $label2
end
local.get $var3
local.get $var3
i32.load offset=4
i32.const 1
i32.add
i32.store offset=4
local.get $var5
i32.eqz
if
local.get $var0
local.get $var1
call $func13343
br $label3
end
local.get $var4
i64.const 0
i64.store
local.get $var3
local.get $var3
i32.load offset=4
i32.const 1
i32.add
i32.store offset=4
end $label2
local.get $var4
local.get $var3
i32.store offset=4
local.get $var4
local.get $var5
i32.store
local.get $var1
local.get $var4
local.get $var2
i32.load offset=8
call $func15742
local.get $var0
local.get $var1
call $func13343
**unreachable** ;; Why 'unreachable' here?
end $label1
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.