aarzilli / golua

Go bindings for Lua C API - in progress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

exitsyscall: syscall frame is no longer valid

rikonor opened this issue · comments

Hi,

I'm encountering the following panic:

fatal error: exitsyscall: syscall frame is no longer valid
    runtime stack:
    runtime.throw(0xfacd50, 0x2d)
	$GOROOT/src/runtime/panic.go:596 +0x95
    runtime.exitsyscall.func1()
	$GOROOT/src/runtime/proc.go:2587 +0x36
    runtime.systemstack(0x7fc0ea7fbe88)
	$GOROOT/src/runtime/asm_amd64.s:327 +0x79
    runtime.mstart()
	$GOROOT/src/runtime/proc.go:1132
    goroutine 2857675810 [syscall, locked to thread]:
    runtime.cgocall(0xdfbe60, 0xc4370a51a8, 0xfaa4fd)
	$GOROOT/src/runtime/cgocall.go:131 +0xe2 fp=0xc4370a5168 sp=0xc4370a5128
    golua/lua._Cfunc_lua_pushlstring(0x7f7a9004ef60, 0x7fc0e0265490, 0xa)
	golua/lua/_obj/_cgo_gotypes.go:1154 +0x45 fp=0xc4370a51a8 sp=0xc4370a5168
    golua/lua.(*State).PushString.func2(0x7f7a9004ef60, 0x7fc0e0265490, 0xa)
	$GOPATH/golua/lua/lua.go:385 +0x74 fp=0xc4370a51e0 sp=0xc4370a51a8
    golua/lua.(*State).PushString(0xc4662b8240, 0xf8f104, 0xa)
	$GOPATH/golua/lua/lua.go:385 +0x89 fp=0xc4370a5210 sp=0xc4370a51e0
OMITTED	INTERNAL LIB
    golua/lua.golua_callgofunction(0xc4662b8240, 0x39, 0xc400000008)
	$GOPATH/golua/lua/golua.go:73 +0x6d fp=0xc4370a5290 sp=0xc4370a5240
    golua/lua._cgoexpwrap_cea3daa1dadf_golua_callgofunction(0xc4662b8240, 0x39, 0x38994071e5)
	golua/lua/_obj/_cgo_gotypes.go:1568 +0x35 fp=0xc4370a52b8 sp=0xc4370a5290
    runtime.call32(0x0, 0x7fc0ea7fba38, 0x7fc0ea7fbad0, 0x18)
	$GOROOT/src/runtime/asm_amd64.s:514 +0x48 fp=0xc4370a52e8 sp=0xc4370a52b8
    runtime.cgocallbackg1(0x0)
	$GOROOT/src/runtime/cgocall.go:301 +0x19d fp=0xc4370a5360 sp=0xc4370a52e8
    runtime.cgocallbackg(0x0)
	$GOROOT/src/runtime/cgocall.go:184 +0x84 fp=0xc4370a53c8 sp=0xc4370a5360
    created by net/http.(*Server).Serve
	$GOROOT/src/net/http/server.go:2668 +0x2ce

From my basic understanding of this I think it might be related to setjmp/longjmp calls after which cgo calls into Go, which based on your comments in #53 and in several other places I understand is not allowed.

I'm pretty fuzzy on the details but I realize it's somewhat similar to this issue (mitchellh/go-mruby#49) which is fixed in (mitchellh/go-mruby#50).

Would love to know if you have an idea of what causes this and of a possible fix.

You should take a look at your calls to PushString. You are probably doing something to make it raise a lua exception. If you find out what that is we can put a guard in PushString and return an error.

You are right that this is related to the longjmp/setjmp stuff. I must say, for a language that's all about embedding, supposedly, sprinkling your interpreter with longjmps is not the best idea.

This is a sample snippet, similar to the one where the panic occurs:

...
L.CreateTable(0, 0)
L.PushString("key")
L.PushString("value")
L.SetTable(-3)
...

It seems the panic will occur on either the call to CreateTable or PushString.
It would also seem that this only happens rarely and not on every invocation of the code.

maybe you're out of memory? No clue.