On Sat, Oct 20, 2012 at 1:08 PM, Declan White <deco.da.man@xxxxxxxxx> wrote: > Howdy, > > Either I've gone crazy, or the JIT compiler has a major problem. > > local upvalue > > function test() > local last > for j = 1, 20 do > last = upvalue > end > print(last, upvalue) > end > > for i = 1, 8 do > upvalue = i > test() > end > > > When this code is run with JIT enabled (independent of optimisation flags), > it produces the following output: > > LuaJIT 2.0.0-beta11 (Linux x64) > JIT: ON CMOV SSE2 SSE3 SSE4.1 > 1 1 > 2 2 > 3 3 > 3 4 > 3 5 > 3 6 > 3 7 > 3 8 > > > Which is – as I'm sure you can tell – definitely not correct. > > Lua 5.1 > 1 1 > 2 2 > 3 3 > 4 4 > 5 5 > 6 6 > 7 7 > 8 8 > > > It also occurs on Windows x64 and Windows x86, and I've tested back to > beta10, July 30. > > I have a sneaking suspicion that I've done seriously wrong... how could such > a major bug go unfound for so long? > (If this is intentional, it's definitely not expected!) > This is my reduced use case: http://codepad.org/XH81xmZm > I see the same behavior with LuaJIT-2.0.beta10 (git HEAD as of 2012-09-16, hash=ead325b0c9) on Linux x86. Nasty, indeed! --Leo--