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

inconsistent stack pattern: pt = false, lpt = false, ls = 2, sd = 0 #104

Open
mfateev opened this issue Jan 3, 2020 · 2 comments
Open

Comments

@mfateev
Copy link

mfateev commented Jan 3, 2020

I'm trying to execute the simple Go program compiled to wasm:

maxpro:gowasm maxim$ cat wasm.go
package main

func main() {
}
maxpro:gowasm maxim$ GOOS=js GOARCH=wasm go build -o main.wasm
maxpro:gowasm maxim$ wasm-validate ./main.wasm
maxpro:gowasm maxim$

When trying to execute it using life/main.go I'm getting the following panic:

panic: Error: inconsistent stack pattern: pt = false, lpt = false, ls = 2, sd = 0
---GO TRACEBACK---
goroutine 1 [running]:
runtime/debug.Stack(0x4195060, 0xc000b13a30, 0x4240480)
        /usr/local/go/src/runtime/debug/stack.go:24 +0x9d
github.com/perlin-network/life/utils.CatchPanic(0xc000195a40)
        /Users/maxim/temporal/life/utils/catch.go:11 +0x72
panic(0x4195060, 0xc000b13a30)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/perlin-network/life/compiler.(*SSAFunctionCompiler).Compile(0xc000195988, 0xc00000ad00, 0x13, 0x20)
        /Users/maxim/temporal/life/compiler/ssa.go:339 +0xcb95
github.com/perlin-network/life/compiler.(*Module).CompileForInterpreter(0xc00000e040, 0x0, 0x0, 0xc00016a000, 0x6c5, 0x6cc, 0x0, 0x0)
        /Users/maxim/temporal/life/compiler/module.go:264 +0xa5f
github.com/perlin-network/life/exec.NewVirtualMachine(0xc000162000, 0x228953, 0x228b53, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x10000, ...)
        /Users/maxim/temporal/life/exec/vm.go:437 +0xd0
main.main()
        /Users/maxim/temporal/life/main.go:82 +0x300


goroutine 1 [running]:
main.main()
        /Users/maxim/temporal/life/main.go:89 +0xbe1

Process finished with exit code 2

I do understand that really executing Go program would require polyfilling functions that Go needs, but at least it would be nice to be able to compile and run it until it fails with the first such function.

@mfateev
Copy link
Author

mfateev commented Jan 3, 2020

Commenting out panic at ssa.go:339 lets the module to execute, failing as expected on non
resolved go runtime.nanotime :

Got a connection, launched process /private/var/folders/q2/4s0fwr9s30zbg8qr8tw8y_440000gn/T/___go_build_main_go (pid = 68435).
Resolve func: go runtime.nanotime
--- Begin stack trace ---
<5> [3] 
<4> [800] 
<3> [445] 
<2> [442] 
<1> [735] 
<0> [782] 
--- End stack trace ---
panic: unknown module: go

goroutine 1 [running]:
main.main()
        /Users/maxim/temporal/life/main.go:138 +0x1086
Exiting.

@roman-kashitsyn
Copy link

I have the same issue as well.

In my case the SSA "compiler" can't handle blocks and ifs returning a value, e.g.

block i32
  ; ...
end

if i32
  ; ...
else
  ; ...
end

Commenting out the panic leads to either another panic (e.g., "stack underflow") or invalid intermediate code (which might still produce correct result).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants