Page MenuHomeFreeBSD

lang/lua53: move assertion to correct place
AbandonedPublic

Authored by russ.haley_gmail.com on Mar 31 2019, 5:51 AM.
Tags
None
Referenced Files
F81616899: D19769.id55644.diff
Fri, Apr 19, 1:04 AM
Unknown Object (File)
Sun, Apr 14, 10:41 PM
Unknown Object (File)
Dec 23 2023, 2:02 AM
Unknown Object (File)
Dec 10 2023, 8:32 PM
Unknown Object (File)
Nov 26 2023, 5:01 PM
Unknown Object (File)
Nov 12 2023, 5:34 AM
Unknown Object (File)
Nov 5 2023, 10:24 PM
Unknown Object (File)
Oct 10 2023, 5:32 PM

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
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