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

Termux/aarch64: Segfaults at 97% build progress #230

Closed
athraxkobal opened this issue Mar 12, 2020 · 18 comments · Fixed by #254
Closed

Termux/aarch64: Segfaults at 97% build progress #230

athraxkobal opened this issue Mar 12, 2020 · 18 comments · Fixed by #254

Comments

@athraxkobal
Copy link

athraxkobal commented Mar 12, 2020

Cloning and doing "make regular" works as intended, but building luvi tends to display segfaults at 97% or 98%
The build process runs fine until 97%, where "jitted_tmp/src/lua/init.lua_luvi_generated.o" and
"jitted_tmp/src/lua/luvibundle.lua_luvi_generated.o" both segfault.
At 98%, "jitted_tmp/src/lua/init.lua_luvi_generated.o" segfaults again and "jitted_tmp/deps/lpeg/re.lua_luvi_generated.o" joins the party.

Screenshot: https://cdn.discordapp.com/attachments/598878518570385420/687727043022290992/Screenshot_20200312-1419541.png

This error occasionally pops up around here:
deps/luv/luajit: ./jit/bcsave.lua:0: attempt to compare two table values

@drveoj
Copy link

drveoj commented Apr 28, 2020

Having the same issue. Anyone looked into this yet? Really want to be able to run luvit on my Raspberry PIs :D

@thonkinator
Copy link

thonkinator commented Mar 20, 2021

thanks to Nameless (aka truemedian) for this.
just run these two lines and wait for it to compile:
export PREFIX=.
curl -L https://github.com/truemedian/luvit-bin/raw/main/install.sh | sh

@Bilal2453
Copy link
Contributor

Bilal2453 commented Mar 20, 2021

Just to clear stuff out. The build did indeed work on a aarch64 using that script, not necessary fixed, might just mean your exact setup had a less chance of encountering the same segfault, specially in your case it wasn't a Termux setup. Will have to do more investigating on this.

@squeek502
Copy link
Member

luvit-bin uses make regular-asm while the OP is using make regular. Can anyone confirm if make regular-asm avoids the segfault?

@athraxkobal
Copy link
Author

luvit-bin uses make regular-asm while the OP is using make regular. Can anyone confirm if make regular-asm avoids the segfault?

Tried just now, no.
Screenshot_20210320-200951~2

@truemedian
Copy link
Member

This is making a lot less sense than it should, could it possibly be a Termux bug?

@Bilal2453
Copy link
Contributor

This is making a lot less sense than it should, could it possibly be a Termux bug?

that is a high chance indeed, but according to @drveoj, this did happen with their Raspberry as well as Termux.

Tried just now, no.

@athraxkobal Can you try the instructions in this reply? if you haven't already

export PREFIX=.
curl -L https://github.com/truemedian/luvit-bin/raw/main/install.sh | sh

@athraxkobal
Copy link
Author

@Bilal2453 Fails the exact same way after looking at the install.log

@drveoj
Copy link

drveoj commented Mar 22, 2021

@Bilal2453 Fails the exact same way after looking at the install.log

Happy to pitch in on the Raspberry side if I can help...

@truemedian
Copy link
Member

I've debugged this farther than I wanted to, it appears to be a bug in aarch64 luajit. If anyone has an actual aarch64 machine and the knowledge, we might want to submit a bug report to luajit about this.

@drveoj
Copy link

drveoj commented Mar 22, 2021

Just to confirm (for the absence of doubt) this doesn't work on PI(4)

Linux ember 5.4.0-1030-raspi #33-Ubuntu SMP PREEMPT Wed Feb 24 11:20:11 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux

curl -L https://github.com/truemedian/luvit-bin/raw/main/install.sh | sh yeilds:

[ 97%] Building Luajitted /home/joev/bot/luvi.d/src/lua/luvibundle.lua: /home/joev/bot/luvi.d/build/jitted_tmp/src/lua/luvibundle.lua_luvi_generated.o
make[2]: *** [CMakeFiles/luvi.dir/build.make:73: jitted_tmp/src/lua/luvibundle.lua_luvi_generated.o] Segmentation fault (core dumped)
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/luvi.dir/build.make:63: jitted_tmp/src/lua/init.lua_luvi_generated.o] Segmentation fault (core dumped)
make[2]: *** [CMakeFiles/luvi.dir/build.make:78: jitted_tmp/deps/lpeg/re.lua_luvi_generated.o] Segmentation fault (core dumped)
make[2]: *** [CMakeFiles/luvi.dir/build.make:68: jitted_tmp/src/lua/luvipath.lua_luvi_generated.o] Segmentation fault (core dumped)
make[1]: *** [CMakeFiles/Makefile2:190: CMakeFiles/luvi.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

@wozeparrot
Copy link

I bisected luajit to this bad commit: 3143b218946395834f0bfef741061ac6ef3f5b56.

Not really sure how to proceed from here.

@Bilal2453
Copy link
Contributor

Bilal2453 commented Oct 19, 2021

Can indeed confirm it compiles just fine on aarch64 using make regular on the commit before 3143b218, 78f5f1cef. Thanks @wozeparrot, now good luck knowing how that commit broke things, it is quite a large one.

Edit: Do note that both latest LuaJIT and the problematic commit compile just fine under aarch64 with default make flags.

@wozeparrot
Copy link

Managed to get luvi to compile with commit 3143b218.

Seemingly the issue with commit 3143b218 is that when building luajit, luv isn't passing the correct flags to DASM to set the endianness.

By patching the luajit.cmake file in luv to add -DENDIAN_LE to DASM_FLAGS will allow luvi to build with no issues on aarch64.

@squeek502
Copy link
Member

squeek502 commented Oct 21, 2021

By patching the luajit.cmake file in luv to add -DENDIAN_LE to DASM_FLAGS will allow luvi to build with no issues on aarch64.

Could TestBigEndian/CMAKE_C_BYTE_ORDER be used to determine when to pass this flag? Or should it always be passed?

@truemedian
Copy link
Member

A quick glance at Luajit's makefile shows that luvit's cmake file for building luajit is out of sync.

luvit vs luajit. I'll take a look at this in more detail so that this same issue doesn't pop back up on us and submit a PR to luv.

@wozeparrot
Copy link

By patching the luajit.cmake file in luv to add -DENDIAN_LE to DASM_FLAGS will allow luvi to build with no issues on aarch64.

Could TestBigEndian/CMAKE_C_BYTE_ORDER be used to determine when to pass this flag? Or should it always be passed?

You should pass -DENDIAN_LE for little endian and -DENDIAN_BE for big endian. So this should be tested for and handled accordingly.

@truemedian
Copy link
Member

If endianness does actually happen to be the only issue here, then luvit/luv#570 should fix this issue once and for all.

However, in the interest of keeping the rest of the cmake file still functional on older versions of luajit I only added the few missing things. In the future it probably needs to be reworked or redone to be more in line with the current luajit makefile.

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

Successfully merging a pull request may close this issue.

7 participants