actboy168 / bee.lua

Lua runtime and toolset
MIT License
160 stars 30 forks source link

Test compile failure on Linux #8

Closed wbthomason closed 4 years ago

wbthomason commented 4 years ago

Related to https://github.com/sumneko/lua-language-server/issues/160, https://github.com/actboy168/bee.lua/blob/590917dd1575368a3b26ac2befa392bb82aae4b4/ninja/linux.ninja#L147 causes a build failure. Removing this target from linux.ninja allows the build to succeed.

actboy168 commented 4 years ago

It seems that a test caused the crash. You can use this to see which test caused the crash.

build/linux/bin/bootstrap test/test.lua -v
wbthomason commented 4 years ago

I get the following output:

❯ build/linux/bin/bootstrap test/test.lua -v
OS:         Linux
Arch:       64
Compiler:   GCC 10.1.0
CRT:        libstdc++ 20200507
DEBUG:      false
Started on Tue May 26 10:45:53 2020
    test_fs.test_absolute ... Ok
    test_fs.test_absolute_relative ... Ok
    test_fs.test_add_remove_permissions ... Ok
    test_fs.test_concat ... Ok
    test_fs.test_copy_file ... zsh: bus error (core dumped)  build/linux/bin/bootstrap test/test.lua -v
wbthomason commented 4 years ago

Upon further investigation, the culprit seems to be os.clock() as used here: https://github.com/actboy168/bee.lua/blob/590917dd1575368a3b26ac2befa392bb82aae4b4/test/test_filesystem.lua#L533

It seems strange that a built-in would cause a crash, though? Calling os.clock() or tostring(os.clock()) in a Lua 5.3 REPL works as expected, but adding print(tostring(os.clock())) in that test function reliably causes the crash.

actboy168 commented 4 years ago

You can compile a debug version and use gdb to see what happened.

luamake rebuild -mode debug
wbthomason commented 4 years ago

Sorry, but I'm having a bit of difficulty with this. I don't see a luamake binary in the repo - where should this come from?

actboy168 commented 4 years ago

https://github.com/actboy168/luamake

wbthomason commented 4 years ago

Hmm. When I do luamake rebuild -mode debug and then gdb --args build/linux/bin/bootstrap test/test.lua and run (inside gdb), I cannot replicate the test failure.

It seems that this failure only occurs when luamake is built in release mode.

That is, when I run luamake rebuild -mode debug all 85 tests pass correctly, whereas when I run luamake rebuild -mode release I get this build error.

wbthomason commented 4 years ago

When I use gdb on the release build, even though I don't get debug symbols, it appears that the error is caused by receiving SIGBUS while in snprintf in libc.

My system glibc version is 2.31-5

wbthomason commented 4 years ago

Is there any update on this issue? I am still having the build failure; I'm happy to do more to try and track down the cause, but I'm not sure what would help at this point.

actboy168 commented 4 years ago

I think this is a bug of gcc, you can reduce the optimization level to avoid it.e.g. -optimize size or -optimize off