Skip to content

Conversation

@squeek502
Copy link
Member

@squeek502 squeek502 commented Dec 30, 2025

Intended to close #787

However, Lua 5.5.0 seems to somehow introduce regressions in our thread and work tests. Some of the thread tests hang, and the test threadpool test of test-work fails with

Uncaught Error: ./tests/test-work.lua:24: attempt to perform arithmetic on a nil value (local 'n')
stack traceback:
        ./tests/test-work.lua:24: in function <./tests/test-work.lua:23>
        [C]: in field 'run'
        ./lib/tap.lua:61: in function <./lib/tap.lua:48>
        [C]: in global 'xpcall'
        ./lib/tap.lua:48: in upvalue 'run'
        ./lib/tap.lua:146: in local 'tap'
        tests/run.lua:23: in main chunk
        [C]: in ?

Need to figure out what's going on. The documented incompatibilities don't seem relevant on first glance.

@truemedian
Copy link
Member

The list of incompatibilities isn't very descriptive, but the clang-asan test fails that we're getting a null string from dumping the function and the rest of the tests are failing as if the thread didn't start with the function we expect.

So this seems to have been a change with respect to how lua_dump works.

The implementation of string.dump in Lua 5.5 has an additional branch that we likely need to reproduce: https://www.lua.org/source/5.5/lstrlib.c.html#writer

@squeek502
Copy link
Member Author

squeek502 commented Jan 1, 2026

Thanks, your comment got me pointed in the right direction. luv_thread_dumped should now be much more resilient against future changes to the details of lua_dump as well.

With Lua 5.5, the previous code would end up with `nil` as the top before returning. Instead of changing the logic conditionally by checking the Lua version, the logic has been changed to not need to care about the details of how lua_dump/luaL_pushresult push/pop from the stack by pushing a placeholder onto the stack and using that for the result.
Lua 5.5.0 does not handle tables created with `nil` as an element in the same way as previous Lua versions did. For example, this:

    local t = {"foo", nil, "bar"}
    print(#t)

will print 3 with Lua < 5.5.0, but 1 with Lua 5.5.0. This means that all args past the `nil` in these test cases would not be unpacked when running with Lua 5.5.0.

Additionally, the behavior these tests relied on only *happened* to work for LuaJIT, as LuaJIT will also print 1 in the example above but will e.g. print 6 with the particular table used in our `test-thread` cases.
@squeek502 squeek502 merged commit cc1960c into luvit:master Jan 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Lua 5.5

2 participants