Skip to content

stuck when xpcall #464

@Junyang-Liu

Description

@Junyang-Liu
  1. What version of GopherLua are you using?

[email protected]

  1. What version of Go are you using? :

go version go1.21.4 darwin/amd64

  1. What operating system and processor architecture are you using?

Mac OS Catalina 10.15.3 x86_64

  1. What did you do?

i do this: (go) L.DoFile -> (lua)xpcall -> (lua)dofile
here the code
golang:

   L := lua.NewState()
   defer L.Close()

   if err := L.DoFile("init.lua"); err != nil {
   	fmt.Println(err.Error())
   }

init.lua

xpcall(dofile, printErr, "first.lua")	-- not work

first.lua

print("sth.")
  1. What did you expect to see?

:L.DoFile should return,and first.lua should run

  1. What did you see instead?

:go stuck there, only happens when xpcall -> dofile

➜  goluadofile ls
first.lua init.lua  run.go
➜  goluadofile go run ./run.go
start go run
[init] start
run_path:	init
^Csignal: interrupt

always stuck until ^C to interrupt it.

  1. here are all source code files:
    run.go
package main

import (
	"fmt"

	lua "github.com/yuin/gopher-lua"
)

func main() {
	fmt.Println("start go run")

	L := lua.NewState()
	defer L.Close()

	if err := L.DoFile("init.lua"); err != nil {
		fmt.Println(err.Error())
	}
	fmt.Println("end go run")
}

init.lua

local function printErr(err)
	print(err)
	print(debug.traceback())
end

local function test( ... )
	print("is test function run, args: ", ...)
end

run_path = "init"
print("[init] start")


print("run_path:", run_path)

-- xpcall(test, printErr, "test")	-- work fine

-- dofile("first.lua")			-- work fine

-- pcall(dofile, "first.lua")	-- work fine

xpcall(dofile, printErr, "first.lua")	-- not work


print("run_path:", run_path)

print("[init] end")

first.lua

print("[first] start")
run_path = "first"
print("[first] end")
  1. I don’t know if I set lua.NewState() up wrong, never mind to give more information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions