luajit2 icon indicating copy to clipboard operation
luajit2 copied to clipboard

Failed test when running ffi_bit64.lua in v2.1-20200102

Open amdei opened this issue 4 years ago • 5 comments

Debian 10 Buster x64

# gcc --version
gcc (Debian 8.3.0-6) 8.3.0

On clean system:

git clone https://github.com/openresty/luajit2.git
cd luajit2
git checkout v2.1-20200102
export LUAJIT_PREFIX=/opt/luajit21
export LUAJIT_COMMON_XCFLAGS="-DLUA_USE_APICHECK -DLUA_USE_ASSERT -DLUAJIT_NUMMODE=2 -msse4.2 -O1"
export LUAJIT_XCFLAGS="$LUAJIT_COMMON_XCFLAGS"

make -j `nproc` PREFIX=$LUAJIT_PREFIX XCFLAGS="$LUAJIT_XCFLAGS"
make install PREFIX=$LUAJIT_PREFIX

git clone https://github.com/openresty/luajit2-test-suite.git ../luajit2-test-suite
cd ../luajit2-test-suite
./run-tests -j 4 /opt/luajit21

As a result, I've got:

...
=== test/ffi/ffi_bit64.lua
/opt/luajit21/bin/luajit-2.1.0-beta3: ffi_bit64.lua:18: assertion failed!
stack traceback:
        [C]: in function 'assert'
        ffi_bit64.lua:18: in main chunk
        [C]: at 0x557ea2555190
Failed test when running /opt/luajit21/bin/luajit-2.1.0-beta3 ffi_bit64.lua 1: 256
...

test/ffi/ffi_bit64.lua:18 is:

assert(tostring(band(1ll, 1, 1ull, -1)) == "1ULL")

What's wrong with my setup? How can I overcome this issue?

Actual result of this snippet:

local bit = require("bit")
local band = bit.band
print(tostring(band(1ll, 1, 1ull, -1)))

is 0ULL

amdei avatar Apr 22 '20 01:04 amdei

I've tried to add -DLUAJIT_ENABLE_LUA52COMPAT, as sugested in #87, but result is the same.

amdei avatar Apr 22 '20 01:04 amdei

@amdei I copied your shell commands and ran them on a relatively clean Debian buster x86_64 system on my side and could not reproduce the test failure you are seeing:

$ /opt/luajit21/bin/luajit test/ffi/ffi_bit64.lua; echo $?
0

Will you run that ffi_bit64.lua file separately like above on your side?

I also tried your build flags and the same git tag (v2.1-20200102) on my Fedora 28 x86_64 sysetm and could not reproduce any test failures at all.

BTW, you need to set LUA52=1 env when running ./run-tests. But it should be irrelevant to the ffi_bit64.lua failure you are seeing.

I guess there may be something strange in your system environment. Not sure. You'll need to dig into that assertion failure with tools like gdb on your side. Too little information is currently known.

agentzh avatar Apr 22 '20 04:04 agentzh

BTW, i'm also using the default gcc in Debian 10:

$ gcc --version
gcc (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

agentzh avatar Apr 22 '20 04:04 agentzh

@agentzh Thanks a lot for a prompt reply!

Seems you're right - something was wrong with my system...

Tried with other two different fresh and clean Debian 9&10 VMs. Unable to reproduce issue on them with the script from my initial message either.

At the same time, when I try to specify LUA52 on tests run:

LUA52=1 ./run-tests -j 1 /opt/luajit21

it fails 7 other tests.

Tried to specify LUA52=1 on compile time too:

export LUAJIT_XCFLAGS="$LUAJIT_COMMON_XCFLAGS" LUA52=1

with much better result - all test has passed!

So, one need to specify LUA52=1 on compile time, and everything will be Ok. :-)

amdei avatar Apr 22 '20 07:04 amdei

BTW, after adding of LUA52=1 to my initial sript:

export LUAJIT_XCFLAGS="$LUAJIT_COMMON_XCFLAGS" LUA52=1

all test has passed on machine, where they failed in the first place.

So, complete "working for me" example is the following:

export LUAJIT_COMMON_XCFLAGS="-DLUAJIT_ENABLE_LUA52COMPAT -DLUA_USE_APICHECK -DLUA_USE_ASSERT -DLUAJIT_NUMMODE=2 -msse4.2 -O1"
export LUAJIT_XCFLAGS="$LUAJIT_COMMON_XCFLAGS" LUA52=1

make -j `nproc` PREFIX=$LUAJIT_PREFIX XCFLAGS="$LUAJIT_XCFLAGS"
make install PREFIX=$LUAJIT_PREFIX

amdei avatar Apr 22 '20 07:04 amdei