LuaLanes / lanes

Lanes is a lightweight, native, lazy evaluating multithreading library for Lua 5.1 to 5.4.
Other
465 stars 96 forks source link

deadlock during linda operation in specific circumstances #228

Closed benoit-germain closed 4 months ago

benoit-germain commented 5 months ago

linda_perf.lua crashes with Lua < 5.4. I suspect it is an interaction with the behavior of the garbage collector. My hypothesis is that the linda operation from the current test run can trigger GC, causing the collection of another linda from a previous run, that happens to be relying on the same keeper state. During collection, the second linda attempts to acquire access to the keeper state for cleanup, which can cause a deadlock because the first linda still has access. This doesn't happen with C-implementation, because the keepers use a recursive mutex. If the hypothesis is true, adding more keeper states to Lanes configuration and assigning each new linda to a separate keeper should "fix" the deadlock. potential fix: suspend gc during linda operation.

benoit-germain commented 4 months ago

Fixed by d93e1fcea482f8348bb42171befea08466f8541f