Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OOB table access with singlepass backend #2782

Closed
kateinoigakukun opened this issue Feb 7, 2022 · 1 comment · Fixed by #2787
Closed

OOB table access with singlepass backend #2782

kateinoigakukun opened this issue Feb 7, 2022 · 1 comment · Fixed by #2787
Assignees
Labels
bug Something isn't working priority-high High priority issue
Milestone

Comments

@kateinoigakukun
Copy link
Contributor

kateinoigakukun commented Feb 7, 2022

Describe the bug

singlepass backend somehow emits instructions that can cause unexpected OOB in table access.
llvm and cranelift backend doesn't reproduce this issue. Also this issue has been introduced since 2.2.0-rc1

$ echo "`wasmer -V` | `rustc -V` | `uname -m`"
wasmer 2.2.0-rc1 | rustc 1.56.1 (59eed8a2a 2021-11-01) | x86_64

Steps to reproduce

VarArgs.swift.wasm.zip

$ wasmer run --singlepass VarArgs.swift.wasm

Expected behavior

$ wasmer run --singlepass VarArgs.swift.wasm
The answer to life and everything is 42, 42, -42, 3.141593
dig it: 0  0 -1  1 -2  2 -3  3 -4  4 -5  5 -6  6 -7  7 -8  8 -9  9 -10 10 -11 11
pointers: '0x12345670' '0x12345671' '0x12345672' '0x12345673' '0x12345674'
a 1.1 1 2.2 1 3.3 1 a
b 1 1.1 1 2.2 1 3.3 1 b
c 1 2 1 3 1 4444444444444444 1 c
d 1 1 2 1 3 1 4444444444444444 1 d
e 10 20 10 30 10 4040404040404040 10 e
f 10 10 20 10 30 10 4040404040404040 10 f
rdar-32547102: 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0
a 1.1 1 2.2 1 4.5 1 1.1 a
b 1 1.1 1 2.2 1 4.5 1 1.1 b
done.

Actual behavior

$ wasmer run --singlepass VarArgs.swift.wasm
error: failed to run `VarArgs.swift.wasm`
│   1: RuntimeError: undefined element: out of bounds table access
╰─▶ 2: table_get_oob

Additional context

This issue was found in SwiftWasm's CI: swiftwasm/swift#4203

@kateinoigakukun kateinoigakukun added the bug Something isn't working label Feb 7, 2022
@syrusakbary
Copy link
Member

Side note: this seemed to be working in Wasmer 2.1.1

@syrusakbary syrusakbary added this to the v2.x milestone Feb 7, 2022
@wchaudry wchaudry added this to 🌱 In progress in Wasmer Runtime Issue Board Feb 9, 2022
@Amanieu Amanieu added the priority-high High priority issue label Feb 9, 2022
@bors bors bot closed this as completed in 2b396e0 Feb 14, 2022
Wasmer Runtime Issue Board automation moved this from 🌱 In progress to 🎉 Done Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-high High priority issue
Projects
Development

Successfully merging a pull request may close this issue.

4 participants