[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: 5.4 luaL_checkversion vs. loadlib()
- From: Andrew Gierth <andrew@...>
- Date: Tue, 16 Jul 2019 15:51:01 +0100
Prior to 5.4, luaL_checkversion checks that there isn't more than one
copy of the interpreter code involved, that is to say that a static
variable will have the same address regardless of what module it got
5.4 abandons this check; apparently it was believed to be unnecessary?
But I think it _is_ necessary and that you can probably (I haven't
actually done the test case yet) get unexpected errors from having
multiple copies of the interpreter. Specifically, ll_loadlib relies on
registry[&CLIBS], where &CLIBS is a lightuserdata with the address of a
static var. If there are multiple copies of the interpreter and you call
require or loadlib from one other than the one that created the state,
it'll end up calling lua_getfield on a nil value, which will throw an
Am I wrong?