Re: [luatex] Using `libtrash` makes lualatex crash
On Fri, 4 Apr 2025 at 10:19, Werner LEMBERG wrote: > > On my platform version (openSUSE 15.6), version 2.38 of the GNU C > Library is used. Are there known problems with lua and this glibc > version? unrelated (just in case you use a rolling distro): gcc 15 very likely will not compile luatex as is now because it set C23 as default https://gcc.gnu.org/gcc-15/porting_to.html#c23 """ GCC 15 changes the default language version for C compilation from -std=gnu17 to -std=gnu23. """ Luatex still compiles with export CFLAGS="-std=gnu17" (the previous default) ( I have checked it with gcc (GCC) 15.0.1 20250323 (experimental)) -- luigi
Re: [luatex] Using `libtrash` makes lualatex crash
> gcc 15 very likely will not compile luatex as is now > because it set C23 as default > https://gcc.gnu.org/gcc-15/porting_to.html#c23 > """ > GCC 15 changes the default language version for C compilation from > -std=gnu17 to -std=gnu23. > """ > > Luatex still compiles with > export CFLAGS="-std=gnu17" (the previous default) > ( I have checked it with gcc (GCC) 15.0.1 20250323 (experimental)) OK, thanks for the heads-up. Werner
Re: [luatex] Using `libtrash` makes lualatex crash
Hi Werner, On Fri, 2025-04-04 at 11:01 +, Werner LEMBERG wrote: > > There are 4 possible combinations that you could try: > > > > LD_PRELOAD= texluac -o test.luc test.lua \ > > && LD_PRELOAD= texlua loader.lua > > LD_PRELOAD=libtrash.so texluac -o test.luc test.lua \ > > && LD_PRELOAD= texlua loader.lua > > These two work. > > > LD_PRELOAD= texluac -o test.luc test.lua \ > > && LD_PRELOAD=libtrash.so texlua loader.lua > > LD_PRELOAD=libtrash.so texluac -o test.luc test.lua \ > > && LD_PRELOAD=libtrash.so texlua loader.lu > > These two crash, only showing 'C'. Ok, so the issue is with loading the bytecode, not with creating it. > OK, thanks. So: lua 5.3.6 coming with openSUSE 15.6 works/crashes in > exactly the same way as above. > > I also tested lua versions 5.1.5 and 5.4.4, which also come with > openSUSE: with 5.1.5, everything works fine; with 5.4.4, it crashes in > the same way. Alright, so the issue seems to be in Lua somewhere, and not LuaTeX itself. But plenty of other programs embed Lua, so it's interesting that LuaTeX is the only/first place that this bug showed up for you. I also tried installing libtrash on my computer, and everything works properly with libtrash v3.8 and Lua v5.4.7. So the issue seems to depend on something specific with your installation, although I have no idea what. Is it something to do with FORTIFY_SOURCE or a weird ABI mismatch maybe? Thanks, -- Max
Re: [luatex] Using `libtrash` makes lualatex crash
> I also tried installing libtrash on my computer, and everything works > properly with libtrash v3.8 and Lua v5.4.7. Aaah! I'm using libtrash v3.9 – downgrading to v3.8 makes everything work again. What a relief. Thanks a lot for your help! I've submitted a bug report for libtrash. https://github.com/pete4abw/libtrash/issues/7 Werner
Re: [luatex] Using `libtrash` makes lualatex crash
> There are 4 possible combinations that you could try: > > LD_PRELOAD= texluac -o test.luc test.lua \ > && LD_PRELOAD= texlua loader.lua > LD_PRELOAD=libtrash.so texluac -o test.luc test.lua \ > && LD_PRELOAD= texlua loader.lua These two work. > LD_PRELOAD= texluac -o test.luc test.lua \ > && LD_PRELOAD=libtrash.so texlua loader.lua > LD_PRELOAD=libtrash.so texluac -o test.luc test.lua \ > && LD_PRELOAD=libtrash.so texlua loader.lu These two crash, only showing 'C'. > Ah, I mean the standalone Lua program, nothing to do with TeX. I > think that this is the correct package for OpenSUSE: > > https://software.opensuse.org/package/lua53 OK, thanks. So: lua 5.3.6 coming with openSUSE 15.6 works/crashes in exactly the same way as above. I also tested lua versions 5.1.5 and 5.4.4, which also come with openSUSE: with 5.1.5, everything works fine; with 5.4.4, it crashes in the same way. > Do you have snapper enabled on your root partition? Sorry, no. I've set up my OS from scratch just a few days ago. Werner
Re: [luatex] Using `libtrash` makes lualatex crash
Hi Werner,
On Fri, 2025-04-04 at 08:19 +, Werner LEMBERG wrote:
> > If you put the following contents into a file called .lua
> >
> > #!/usr/bin/env texlua
> > print(dofile
> > "/home/wl/.texlive2025/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc")
> >
> > and run it with
> >
> > LD_PRELOAD=/usr/local/lib64/libtrash.so texlua .lua
> >
> > what does it output? It should output something like
> >
> > table: 0x116dddb0
> >
> > (the exact hex number doesn't matter) If it doesn't output that or
> > crashes,
>
> It crashes. The topmost elements of the function stack gdb shows are
> the same as with the originally reported crash.
Hmm, interesting. There's certainly nothing there that involves file
deletion, so it looks like libtrash is crashing the bytecode loader,
which doesn't really make any sense.
> I'm willing to debug
> this further if you tell me how to do that.
You can try a minimal test case of writing/loading Lua bytecode:
$ echo 'print("A") return "B"' > test.lua
$ texlua test.lua
A
$ texluac -o test.luc test.lua
$ echo 'print("C") print(dofile("test.luc")) print("D")' > loader.lua
$ texlua loader.lua
C
A
B
D
There are 4 possible combinations that you could try:
LD_PRELOAD= texluac -o test.luc test.lua && LD_PRELOAD= texlua loader.lua
LD_PRELOAD=libtrash.so texluac -o test.luc test.lua && LD_PRELOAD= texlua
loader.lua
LD_PRELOAD= texluac -o test.luc test.lua && LD_PRELOAD=libtrash.so texlua
loader.lua
LD_PRELOAD=libtrash.so texluac -o test.luc test.lua &&
LD_PRELOAD=libtrash.so texlua loader.lua
Hopefully that should narrow it down to if it's writing or loading the
bytecode that's the issue.
> > can you try running Lua 5.3 (Lua 5.4 won't work) on that same file?
>
> How do I do that? Looking into `./build.sh` I see that
> ```
> BUILDLUA53=TRUE
> ```
> is the default...
Ah, I mean the standalone Lua program, nothing to do with TeX. I think
that this is the correct package for OpenSUSE:
https://software.opensuse.org/package/lua53
> I had another idea and tried various checkouts of the TeXLive
> repository, going back to the beginning of the year 2023: lualatex
> always crashes. Since I know with 100% certainty that it worked for
> me then, my conclusion is that a change in one of the necessary DLLs
> rather than a change in luatex per se causes the problem
Do you have snapper enabled on your root partition? If so, you can use
systemd-nspawn to bisect which OS update caused the issue. Make sure
that there's a copy of the current LuaTeX binary somewhere in your home
folder, then you can run
sudo systemd-nspawn \
--console=autopipe \
--directory=/.snapshots//snapshot/ \
--ephemeral \
--user=$USER \
--bind-ro=/home/ --overlay=+/home::/home \
$HOME/path/to/texlua your-test-file.lua
for different values of and see if that changes anything.
> On my platform version (openSUSE 15.6), version 2.38 of the GNU C
> Library is used. Are there known problems with lua and this glibc
> version?
Not that I'm aware of. I'm using glibc 2.40 (on Fedora 41 x86_64) and
I've compiled and ran LuaTeX without any issues.
> I no longer think that a recent change caused that. However, if you
> still think I should do that, I can give it a try.
I agree that this probably wasn't caused by a recent change in LuaTeX,
so there's probably no point in bisecting.
Thanks,
-- Max
Re: [luatex] Using `libtrash` makes lualatex crash
On Fri, 4 Apr 2025 at 10:19, Werner LEMBERG wrote: > OK, thanks for the information. > I no longer think that a recent change caused that. However, if you > still think I should do that, I can give it a try. > I will check it this evening . -- luigi
Re: [luatex] Using `libtrash` makes lualatex crash
Hello Max, thanks for the reply. > If you put the following contents into a file called .lua > > #!/usr/bin/env texlua > print(dofile > "/home/wl/.texlive2025/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc") > > and run it with > > LD_PRELOAD=/usr/local/lib64/libtrash.so texlua .lua > > what does it output? It should output something like > > table: 0x116dddb0 > > (the exact hex number doesn't matter) If it doesn't output that or > crashes, It crashes. The topmost elements of the function stack gdb shows are the same as with the originally reported crash. I'm willing to debug this further if you tell me how to do that. > can you try running Lua 5.3 (Lua 5.4 won't work) on that same file? How do I do that? Looking into `./build.sh` I see that ``` BUILDLUA53=TRUE ``` is the default... > Another thing that you can try is deleting the entire contents of > ~/.texlive2025/texmf-var/luatex-cache, and then compile simple.tex > again. I did that, and the first time calling lualatex succeeds – as expected, since the font cache is empty. The second time it crashes, so there is indeed a problem with reading the created font cache files. >> I thus think the problem must have been introduced rather recently >> (i.e., within the last few weeks) – or maybe I was just lucky, and >> other changes in TeXLive accidentally started to trigger the crash. > > Luigi and Hans will know better than I do, but I don't think that > there have been any changes in LuaTeX recently that would have > caused this. OK, thanks for the information. I had another idea and tried various checkouts of the TeXLive repository, going back to the beginning of the year 2023: lualatex always crashes. Since I know with 100% certainty that it worked for me then, my conclusion is that a change in one of the necessary DLLs rather than a change in luatex per se causes the problem (alternatively, it now exposes an already earlier existing bug) – most likely something in the GNU C library. I'm not an expert in this area, so I might be wrong, of course. On my platform version (openSUSE 15.6), version 2.38 of the GNU C Library is used. Are there known problems with lua and this glibc version? > But you can try running "git bisect" against the main repo > > https://gitlab.lisn.upsaclay.fr/texlive/luatex > > if you think that the problem was caused by a recent change. (Tip: > run "build.sh" with the "--make" and "--parallel" flags to > significantly speed up the repeated builds). I no longer think that a recent change caused that. However, if you still think I should do that, I can give it a try. Werner
Re: [luatex] Using `libtrash` makes lualatex crash
Hi Werner, On Fri, 2025-04-04 at 05:16 +, Werner LEMBERG wrote: > I've run `./build --debug` from the > current luatex repository and copied the resulting binary into the > TeXLive tree as `luahbtex`. [I know that I haven't actually built > `luahbtex` but this doesn't matter for the problem at hand Running `./build.sh --debug --luahb` should also build luahbtex (but I agree that it shouldn't matter here). > #0 0x77c9bb33 in freopen64 () from /lib64/libc.so.6 > #1 0x77fbb574 in return_real_function (function=, > path=, > mode=, mode_str=, flags=, > stream=) > at open-funs.c:291 > #2 0x77fbb9a7 in do_fopen_or_freopen_or_open > (function=function@entry=6, > path=0x63f46f8 > "/home/wl/.texlive2025/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc") > at open-funs.c:569 > #3 0x77fbbd69 in freopen64 (path=, mode= out>, > stream=) at open-funs.c:135 > #4 0x0070273d in luaL_loadfilex (L=0x1085768, > filename=0x63f46f8 > "/home/wl/.texlive2025/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc", > mode=0x0) at ../../../source/libs/lua53/lua53-src/src/lauxlib.c:721 > #5 0x0046ad26 in luatex_loadfile (L=0x1085768) > at ../../../source/texk/web2c/luatexdir/lua/luastuff.c:239 > #6 0x007091c8 in luaD_precall (L=0x1085768, func=0x311c8d0, > nresults=1) > at ../../../source/libs/lua53/lua53-src/src/ldo.c:434 > #7 0x0072696e in luaV_execute (L=0x1085768) > at ../../../source/libs/lua53/lua53-src/src/lvm.c:1134 > #8 0x00709564 in luaD_call (L=0x1085768, func=0x311c540, nResults=1) > at ../../../source/libs/lua53/lua53-src/src/ldo.c:499 > #9 0x007095c2 in luaD_callnoyield (L=0x1085768, func=0x311c540, > nResults=1) > at ../../../source/libs/lua53/lua53-src/src/ldo.c:509 > #10 0x006ffeab in f_call (L=0x1085768, ud=0x7fffd500) > at ../../../source/libs/lua53/lua53-src/src/lapi.c:943 > #11 0x00708562 in luaD_rawrunprotected (L=0x1085768, f=0x6ffe76 > , ud=0x7fffd500) > at ../../../source/libs/lua53/lua53-src/src/ldo.c:142 > #12 0x00709d72 in luaD_pcall (L=0x1085768, func=0x6ffe76 , > u=0x7fffd500, > old_top=704, ef=0) at ../../../source/libs/lua53/lua53-src/src/ldo.c:729 > #13 0x006fff7a in lua_pcallk (L=0x1085768, nargs=3, nresults=1, > errfunc=0, ctx=0, k=0x0) > at ../../../source/libs/lua53/lua53-src/src/lapi.c:969 The crash appears to be in Lua "dofile" function, which is a part of Lua, and not one of the LuaTeX additions. If you put the following contents into a file called .lua #!/usr/bin/env texlua print(dofile "/home/wl/.texlive2025/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc") and run it with LD_PRELOAD=/usr/local/lib64/libtrash.so texlua .lua what does it output? It should output something like table: 0x116dddb0 (the exact hex number doesn't matter) If it doesn't output that or crashes, can you try running Lua 5.3 (Lua 5.4 won't work) on that same file? But if it runs without crashing with texlua, then there's no need to try Lua 5.3. Another thing that you can try is deleting the entire contents of ~/.texlive2025/texmf-var/luatex-cache, and then compile simple.tex again. > I thus think the problem must have been > introduced rather recently (i.e., within the last few weeks) – or > maybe I was just lucky, and other changes in TeXLive accidentally > started to trigger the crash. Luigi and Hans will know better than I do, but I don't think that there have been any changes in LuaTeX recently that would have caused this. But you can try running "git bisect" against the main repo https://gitlab.lisn.upsaclay.fr/texlive/luatex if you think that the problem was caused by a recent change. (Tip: run "build.sh" with the "--make" and "--parallel" flags to significantly speed up the repeated builds). Thanks, -- Max
