lua 5.5 failing on C++ Exceptions (Linux)

220 views
Skip to first unread message

Scott Condit

unread,
Jul 27, 2025, 5:27:28 AMJul 27
to lu...@googlegroups.com
Hello


If building lua as C++ on Debian 6.1.140-1 x86_64, cc is (Debian
12.2.0-14+deb12u1) 12.2.0

It works fine with -DLUA_USE_LONGJMP=1.

Using C++ exceptions however we see:

    coroutine.lua:187: assertion failed!


Naturally the longjump status is 0xFF post LUAI_TRY bubbling up through

    luaD_rawrunprotected

    luaD_closeprotected

    luaD_rawrunprotected

    luaD_closeprotected

    luaE_resetthread

    lua_close_thread

    luaB_close

Regards


Scott


Sainan

unread,
Jul 27, 2025, 6:08:16 AMJul 27
to lu...@googlegroups.com
Could you specify the exact commit hash because coroutine.lua:187 seems to not be anything at master right now (848568790826b7e201f84682185b5b605c473016):

185 end
186
187 -- to-be-closed variables in coroutines
188 local X

-- Sainan

Scott Condit

unread,
Jul 27, 2025, 6:37:30 AMJul 27
to lu...@googlegroups.com

Hello


lua-5.5.0-beta.tar.gz
sha256: 30897f95fc72565cb6c1792f721ad44e1a42e7ac587f62f7587807b3cbff1645

My bad it's coroutine.lua:184

182    assert(st and msg == 20)
183    st, msg = coroutine.close(co)
184    assert(st and msg == nil)

Sainan

unread,
Jul 27, 2025, 6:58:42 AMJul 27
to lu...@googlegroups.com
Well, I compiled Lua as C++ on Ubuntu 22.04.5 using clang version 14.0.0-1ubuntu1.1 and no issues during compilation or with running the coroutine.lua test.

-- Sainan

Sainan

unread,
Jul 27, 2025, 7:02:17 AMJul 27
to lu...@googlegroups.com
Nevermind, I just double-checked my script to build it as C++ and apparently I do set LUA_USE_LONGJMP in it. Commented that out, and now I can reproduce:

$ ../lua coroutine.lua
testing coroutines
to-be-closed variables in coroutines
testing 'coroutine.close'
../lua: coroutine.lua:184: assertion failed!
stack traceback:
[C]: in global 'assert'
coroutine.lua:184: in main chunk
[C]: in ?

-- Sainan

Roberto Ierusalimschy

unread,
Sep 9, 2025, 3:06:38 PMSep 9
to lu...@googlegroups.com
> If building lua as C++ on Debian 6.1.140-1 x86_64, cc is (Debian
> 12.2.0-14+deb12u1) 12.2.0
>
> It works fine with -DLUA_USE_LONGJMP=1.
>
> Using C++ exceptions however we see:
>
>     coroutine.lua:187: assertion failed!

Many thanks for the feedback. Indeed there was a bug there.

-- Roberto
Reply all
Reply to author
Forward
0 new messages