Make sure that main thread is non yieldable

Main thread must be non yieldable even at "level 0" (bare API), outside
the 'pcall' from 'lua.c'.
This commit is contained in:
Roberto Ierusalimschy
2020-07-06 13:54:01 -03:00
parent 6298903e35
commit d39ea8b3ce
3 changed files with 18 additions and 4 deletions

View File

@@ -407,7 +407,8 @@ assert(_G.f() == 12)
if not T then
(Message or print)('\n >>> testC not active: skipping yield/hook tests <<<\n')
(Message or print)
('\n >>> testC not active: skipping coroutine API tests <<<\n')
else
print "testing yields inside hooks"
@@ -564,8 +565,17 @@ else
c == "ERRRUN" and d == 4)
-- using a main thread as a coroutine
-- using a main thread as a coroutine (dubious use!)
local state = T.newstate()
-- check that yielddable is working correctly
assert(T.testC(state, "newthread; isyieldable -1; remove 1; return 1"))
-- main thread is not yieldable
assert(not T.testC(state, "rawgeti R 1; isyieldable -1; remove 1; return 1"))
T.testC(state, "settop 0")
T.loadlib(state)
assert(T.doremote(state, [[