panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x50 pc=0xb1a892]
goroutine 16 [running]:
github.com/yuin/gopher-lua.(*LState).PCall.func1()
C:/Users/admin/go/pkg/mod/github.com/yuin/gopher-lua@v0.0.0-20220504180219-658193537a64/state.go:2020 +0x532
panic({0x1608280, 0x145c120})
C:/Program Files/Go/src/runtime/panic.go:884 +0x213
github.com/yuin/gopher-lua.callGFunction(0xc0000ad6b0, 0x0)
C:/Users/admin/go/pkg/mod/github.com/yuin/gopher-lua@v0.0.0-20220504180219-658193537a64/vm.go:262 +0x2f9
github.com/yuin/gopher-lua.init.3.func26(0xc0000ad6b0, 0x18000000?, 0xc000681000?)
C:/Users/admin/go/pkg/mod/github.com/yuin/gopher-lua@v0.0.0-20220504180219-658193537a64/vm.go:821 +0x379
github.com/yuin/gopher-lua.mainLoop(0xc0000ad6b0, 0xc0000ec600?)
C:/Users/admin/go/pkg/mod/github.com/yuin/gopher-lua@v0.0.0-20220504180219-658193537a64/vm.go:31 +0xfa
github.com/yuin/gopher-lua.(*LState).callR(0xc0000ad6b0, 0x0, 0xffffffffffffffff, 0xc000117f38?)
C:/Users/admin/go/pkg/mod/github.com/yuin/gopher-lua@v0.0.0-20220504180219-658193537a64/state.go:1211 +0x1b4
github.com/yuin/gopher-lua.(*LState).Call(...)
C:/Users/admin/go/pkg/mod/github.com/yuin/gopher-lua@v0.0.0-20220504180219-658193537a64/state.go:1967
github.com/yuin/gopher-lua.(*LState).PCall(0xc0000ad6b0, 0x0, 0xc0000ec600?, 0x0)
C:/Users/admin/go/pkg/mod/github.com/yuin/gopher-lua@v0.0.0-20220504180219-658193537a64/state.go:2030 +0x145
github.com/yuin/gopher-lua.(*LState).DoString(0xc0000ad6b0, {0x18c04d2?, 0x0?})
C:/Users/admin/go/pkg/mod/github.com/yuin/gopher-lua@v0.0.0-20220504180219-658193537a64/auxlib.go:405 +0x6b
github.com/i4de/rulex/test.Test_loop_close.func1()
C:/Users/admin/workspace/rulex/test/calllua_test.go:172 +0x25
created by github.com/i4de/rulex/test.Test_loop_close
C:/Users/admin/workspace/rulex/test/calllua_test.go:171 +0x7d
FAIL github.com/i4de/rulex/test 3.260s
FAIL
This is my lua code:
I run a simple lua file contains a unified loop, When I call
Close(), the program will panic, error in line -> 1390。Please help me resoleve this problemUnit test:
Panic log: