lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hello, everyone!

The system I'm running uses LuaJIT2-beta4 (updated in the middle of May or so) as an engine and
executes everything in coroutines. I noticed the "invalid key to 'next'" error during intensive work the
other day. I inspected the code for things like adding to tables while traversing because several
coroutines could overlap: one is traversing while the other is modifying. Ok, that's clear.

However after that, I noticed the above error again in a simple block under high load:

local cur = {}
for uid, user in pairs(users) do   <--- error appears here!
        table.insert(cur, user)

Here 'users' is the table from which I copy data to 'cur' for next traversal. No metatable is
assigned to it, nothing like that. It is just a table consisting of pairs:
   'uid' (string) => {} (table)

As you can see, I don't modify the contents of the table here in this block nor do I call anything
which could yield the current coroutine or trigger a metamethod or anything which could modify the table.

I'm pretty sure it happens not due to memory corruption or anything. The system is very robust and works for
months until a manual restart. Valgrind tests are brilliant on LuaJIT with all debug options turned
on. The size of 'users' was about 1000 entries and the system was executing a lot of requests when the error happened.

Thanks for any clues in advance.

// Seny