Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amdei opened this issue Apr 22, 2020 · 5 comments
Open

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

amdei opened this issue Apr 22, 2020 · 5 comments

Comments

@amdei
Copy link

amdei commented Apr 22, 2020

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
Copy link
Author

amdei commented Apr 22, 2020

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

@agentzh
Copy link
Member

agentzh commented Apr 22, 2020

@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
Copy link
Member

agentzh commented Apr 22, 2020

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.

@amdei
Copy link
Author

amdei commented Apr 22, 2020

@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
Copy link
Author

amdei commented Apr 22, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants