Closed lx-world closed 3 years ago
They are only safe to be called from Lua code that never calls back to Go
,
why?
Because:
Lua's exceptions are incompatible with Go, golua works around this incompatibility by setting up protected execution environments in lua.State.DoString, lua.State.DoFile and lua.State.Call and turning every exception into a Go panic.
Because:
Lua's exceptions are incompatible with Go, golua works around this incompatibility by setting up protected execution environments in lua.State.DoString, lua.State.DoFile and lua.State.Call and turning every exception into a Go panic.
Thank you very much
A third-party library is called in Lua, such as protoc.lua. If pcall is used in this library, golua will report an error and cannot find pcall. How to solve this?
And , How to understand They are only safe to be called from Lua code that never calls back to Go
?
I use like this,
example:
pcall=unsafe_pcall
Will there be any problems or risks in such use?
Will there be any problems or risks in such use?
No.
Does that mean that I cannot call any third-party libraries with pcall and xpcall?
And, If the third-party library used uses pcall/xpcall, the program will not start. Is there a solution for this?
Does that mean that I cannot call any third-party libraries with pcall and xpcall?
You can but only if there is never any Go frame on the stack between the point where an error is raised and the point where pcall is used.
If the third-party library used uses pcall/xpcall, the program will not start. Is there a solution for this?
Comment out the code that hides pcall, xpcall?
Does that mean that I cannot call any third-party libraries with pcall and xpcall?
You can but only if there is never any Go frame on the stack between the point where an error is raised and the point where pcall is used.
If the third-party library used uses pcall/xpcall, the program will not start. Is there a solution for this?
Comment out the code that hides pcall, xpcall?
Thank you for your answer. Is there any risk in commenting out pcall/xpcall?
Is there any risk in commenting out pcall/xpcall?
Do you mean commenting out the code that hides pcall and xpcall? Yes, all the lua code will have to be audited to make sure that it doesn't use errors + pcall/xpcall in a way that can crash the go runtime.
Why use unsafe_pcall/unsafe_xpcall instead of pcall/xpcall