Page MenuHomeFreeBSD

lang/lua53: move assertion to correct place

Authored by on Mar 31 2019, 5:51 AM.



This patches an issue when the assert option is enabled, which is one of the build options in the port. The patch was provided by


Test Plan

I have no way to test mitigation provided by the patch. However the port build clean when the assert mode option is enabled. Any test suggestions are welcome

Diff Detail

rP FreeBSD ports repository
Lint Skipped
Unit Tests Skipped

Event Timeline

The test case I've been using was posted to lua-l in Feb by Sascha Zelzer, but the archives aren't public so I can't just link to it.

Here it is (though I've increased the iteration count from the original - it's worth playing with that a bit if you can't get it to easily fail). It doesn't always fail, since the window of vulnerability is quite narrow (it fails if a closure is closed over a value-weak or ephemeron (key-weak) table reference in between the final mark/propagation step of a GC cycle and the following atomic step), but I could get occasional assertion failures with this on the old code, and not on the patched version.

local function f()
  local weaktable = setmetatable({}, { __mode = "v" })
  return function()
    local row = weaktable[1]
    if not row then
      row = { a = 1 }
      weaktable[1] = row
    return row

for i=1,100000000 do
  local t = f()()

This has been implemented as a ports option and is already in the tree