[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [luajit2] Bug in luajit compiler exposed by vstruct test suite?
- From: Ben Kelly <ranavin@...>
- Date: Mon, 20 Jun 2011 14:20:49 -0400
Environment: LuaJIT 2.0.0 beta 7, gcc 4.5.2, x86_64
While modifying the vstruct endianness detection code to play nice with
luaJIT, I found that the vstruct test suite failed when run under luajit.
Specifically, whichever floating-point test group ran second would fail, as
would all of the randomly-generated bitmask unpacking tests.
After some investigation, I tracked the problem down to m.unpack[1], the
bitmask-unpacking function (responsible for unpacking strings into lists of
booleans). In the course of trying to debug this, I added a print()...and the
problem went away.
I've now determined the following behaviour:
- with luajit -O3, it runs successfully but gets the wrong answers
- with luajit -O0, the same
- with luajit -joff, it runs normally and all tests pass
- adding jit.off(true, true) to the start of m.unpack also fixes it
It seems likely to me that this is a bug in luajit's compiler, since it runs
fine in lua 5.1 and in luajit in interpreter mode. (Either that or I'm relying
on some implementation-defined or undefined behaviour that happens to be the
same in lua 5.1 and luajit -joff, but I can't find anything.)
I have no experience with luajit and no idea how to start debugging this, so
any help would be appreciated. Unfortunately, I've been unable to create a
minimal test case for this. If you want to reproduce it yourself, you'll need
to do the following:
- download commit 1475192 from github[2]
- unpack it
- cd into the 'ToxicFrog-vstruct-1475192' directory
- run 'env LUA_PATH="" luajit vstruct/test.lua'
- replace "luajit" with "lua", "luajit -joff", and so forth, and observe the
differences
Ben Kelly
[1] https://github.com/ToxicFrog/vstruct/blob/master/vstruct/io/m.lua
[2]
https://github.com/ToxicFrog/vstruct/commit/14751922c00231f3b6bbab4d14f150a346612ec5