Segfault introduced in b82fc3d on v2.1 branch

  • From: Peter Melnichenko <mpeterval@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 9 Jun 2015 15:22:57 +0300

Hello,

LuaJIT 2.1.0 built from v2.1 branch head (4da1bb6) segfaults
on the following code (only with jit on):

local function recurse(expr)
if type(expr) == "table" then
local t = {0}
for i = 1, #expr do
t[i] = recurse(expr[i])
end
end
end

recurse {
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
{
{ 0 },
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
{ 0, 0, 0, 0 }
}
}

I can observe it on all commits starting from b82fc3d. I'm running
32-bit Ubuntu, gcc version is 4.6.3.

The test case is somewhat ugly but reducing it further seems to remove
the segfault. If it helps, at some point during reduction the bug manifested
itself not as a segfault but as a spurious table returned from
one of 'recurse' calls: https://gist.github.com/mpeterv/2362928a80d2b92cb17c

--
Best regards,
Peter

Other related posts: