openresty / luajit2

OpenResty's Branch of LuaJIT 2
https://luajit.org/luajit.html
Other
1.24k stars 200 forks source link

Fix alias check in lj_opt_fwd_alen #157

Closed alfa07 closed 2 years ago

alfa07 commented 2 years ago

The function assumes no aliasing when there is one.

Test case (alen.lua):

local t = {}
local ta = t
local s = 0
for i = 1, 1000 do
  ta[i] = i
  s = s + #t
end
print(s)

Running the test case without fix:

$ luajit -j off alen.lua
500500
$ luajit -j on alen.lua
339799

After fix:

$ luajit -j off alen.lua
500500
$ luajit -j on alen.lua
500500
zhuizhuhaomeng commented 2 years ago

Thank you for your report. Will merge changes from the upstream repo.