Open
Description
Thanks for the bug report!
// wasm.go
package main
import "fmt"
import "github.com/wasmerio/wasmer-go/wasmer"
func native_sum(i uint32, j uint32) (sum uint32) {
return i + j
}
var wasmer_sum_func = func() wasmer.NativeFunction {
// Let's assume we don't have WebAssembly bytes at hand. We
// will write WebAssembly manually.
wasmBytes := []byte(`
(module
(func $add (param $lhs i64) (param $rhs i64) (result i64)
local.get $lhs
local.get $rhs
i64.add)
(memory 65535)
(export "sum" (func $add))
)
`)
// Create an Engine
engine := wasmer.NewEngine()
// Create a Store
store := wasmer.NewStore(engine)
// Let's compile the module.
module, err := wasmer.NewModule(store, wasmBytes)
if err != nil {
fmt.Println("Failed to compile module:", err)
}
// Create an empty import object.
importObject := wasmer.NewImportObject()
// Let's instantiate the WebAssembly module.
instance, err := wasmer.NewInstance(module, importObject)
if err != nil {
panic(fmt.Sprintln("Failed to instantiate the module:", err))
}
// Now let's execute the `sum` function.
sum, err := instance.Exports.GetFunction("sum")
if err != nil {
panic(fmt.Sprintln("Failed to get the `add_one` function:", err))
}
return sum
}()
func main() {
fmt.Println("wasm")
}
//wasm_test.go
func TestWasmerSumFunc(t *testing.T) {
elementCount := 100000
sum_element_1 := make([]int32, elementCount)
sum_element_2 := make([]int32, elementCount)
for i := 0; i < elementCount-1; i++ {
sum_element_1[i] = 10000
sum_element_2[i] = 10000
}
for i := 0; i < elementCount; i++ {
//t.Logf("%T", wasmer_sum_func)
_, err := wasmer_sum_func(sum_element_1[i], sum_element_2[i])
if err != nil {
t.Fatalf("error: %v. a: %v, b: %v", err, sum_element_1[i], sum_element_2[i])
}
//t.Logf("%v", v)
}
}
Describe the bug
golang test failed with the following error message.
SIGBUS: bus error
PC=0x160b0ea75 m=5 sigcode=2 addr=0x160b0ea75
signal arrived during cgo execution
goroutine 6 gp=0xc000007dc0 m=5 mp=0xc00005d808 [syscall]:
Steps to reproduce
- Go to '…'
- Compile with '…'
- Run '…'
- See error
If applicable, add a link to a test case (as a zip file or link to a repository we can clone).
Expected behavior
A clear and concise description of what you expected to happen.
Actual behavior
A clear and concise description of what actually happened.
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Activity