[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 5.4.0-alpha: accessing the Lua state in lua_WarnFunction
- From: Andrew Gierth <andrew@...>
- Date: Fri, 07 Jun 2019 21:04:28 +0100
>>>>> "David" == David Heiko Kolf <david@dkolf.de> writes:
David> Hello,
David> in the manual to Lua 5.4.0-alpha-rc2 I noticed that the
David> lua_WarnFunction that is passed to lua_setwarnf does not get the
David> Lua state as a parameter. Obviously I could still pass the Lua
David> state myself though the "ud" parameter.
David> Is there a reason why the Lua state isn't passed by default? Is
David> it safe to access the Lua state in the warning function?
The WarnFunction is called from somewhere inside the garbage collector
with the state locked, which I'm pretty sure implies that it's not legal
to call any API function from inside it. So the only thing you could
possibly access safely would be any extraspace value you stored with the
state, and in that case you might just as easily pass that, or its
address, as your "ud" parameter.
--
Andrew.