![为什么打印数组会导致 lualatex 冻结?](https://linux22.com/image/429753/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%89%93%E5%8D%B0%E6%95%B0%E7%BB%84%E4%BC%9A%E5%AF%BC%E8%87%B4%20lualatex%20%E5%86%BB%E7%BB%93%EF%BC%9F.png)
以下 MWE 使 lualatex 在我的计算机上陷入无限循环:
\documentclass{minimal}
\usepackage{luacode}
\begin{luacode*}
start = {42};
\end{luacode*}
\begin{document}
\directlua{tex.sprint(tostring(start))}
\end{document}
似乎我需要一个名为的变量start
,并且需要打印一个数组;然后我得到了这个:
This is LuaTeX, Version 1.10.0 (TeX Live 2019/Debian)
restricted system commands enabled.
(./test.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/share/texlive/texmf-dist/tex/latex/base/minimal.cls
Document Class: minimal 2001/05/25 Standard LaTeX minimal class
) (/usr/share/texlive/texmf-dist/tex/lualatex/luacode/luacode.sty
(/usr/share/texlive/texmf-dist/tex/generic/iftex/ifluatex.sty
(/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty))
(/usr/share/texlive/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(/usr/share/texlive/texmf-dist/tex/luatex/ctablestack/ctablestack.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def)
(./test.aux) (/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
之后什么都没发生,我无法使用 Ctrl+C 退出该进程;我需要使用 Ctrl+\ 来终止它。GDB 说 lua 卡在这里:
…
#4 0x00007f0ce05c2f9f in ?? () from /usr/lib/x86_64-linux-gnu/libtexlua53.so.5
#5 0x00007f0ce05b956e in lua_pcallk ()
from /usr/lib/x86_64-linux-gnu/libtexlua53.so.5
#6 0x0000555a19f5f21b in lua_node_filter ()
#7 0x0000555a19f78970 in line_break ()
#8 0x0000555a19eb23c9 in end_graf ()
#9 0x0000555a19eb2429 in ?? ()
#10 0x0000555a19eb07f1 in main_control ()
#11 0x0000555a19eacdfa in main_body ()
#12 0x0000555a19e562c2 in main ()
我有 LuaTeX 版本 1.10.0(TeX Live 2019/Debian)
这是另一个有问题的例子:
\documentclass{minimal}
\usepackage{luacode}
\begin{luacode*}
start = "";
\end{luacode*}
\begin{document}
\directlua{tex.sprint(tostring({42}))}
\end{document}
但这有效:
\documentclass{minimal}
\usepackage{luacode}
\begin{luacode*}
star = "";
\end{luacode*}
\begin{document}
\directlua{tex.sprint(tostring({42}))}
\end{document}