From d39ea8b3ce684728c1ad5005192766d39d2e8baa Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 6 Jul 2020 13:54:01 -0300 Subject: 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'. --- testes/coroutine.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'testes') diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 0a4c2ef3..955f6776 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua @@ -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, [[ -- cgit v1.2.3-55-g6feb