Page MenuHomeFreeBSD

lang/lua53: move assertion to correct place
AbandonedPublic

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

Details

Summary

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 @andrew_tao173.riddles.org.uk.

Reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236891

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

Repository
rP FreeBSD ports repository
Lint
Lint Skipped
Unit
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
    end
    return row
  end
end

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

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