[luatex] segfault with luatex id 7509

Michal Vlasák lahcim8 at gmail.com
Sat Nov 5 16:28:55 CET 2022


On Thu Sep 29, 2022 at 11:58 PM CEST, Werner LEMBERG wrote:
>
> Please unpack the attached tarball and call `./zzz.sh`.  On my
> openSUSE box using a current SVN version of TeXLive, this crashes with
> a segfault.

I think I found the issue and have a fix (attached). (Hans CC'd: I
believe this also applies to LuaMetaTeX.)

The segfaults are in the calls to Lua C API from the function
`load_hyphenation`, which gets called as a result of `\hyphenation`. The
issue is that before pushing to the Lua stack one has to make sure there
is enough free space there (by calling `lua_checkstack`) -- in this case
`load_hyphenation` pushes at most 3 values to the stack. Reserving the
space on the stack should fix the issue.

But I am fairly sure that the stack would (usually) have at least the 3
needed free slots -- after all LuaTeX doesn't reserve stack space too
often, and other things work just fine. This unveiled another problem:
`load_hyphenation` never pops the table it appends to, so many calls to
it slowly exhaust the stack. A call to `lua_pop` is needed at the end.

Patch that adds `lua_checkstack` and `lua_pop` is attached.

Note that the issue exhibits itself so severely because the file
`hyphenation.texi` does `\hyphenation` for each word separately, this is
less efficient and unnecessary, when `\hyphenation` can process many
words just fine.


Michal


PS: I performed the analysis on a slightly older version of LuaTeX and
in a different build environment, though I think the analysis and
conclusions still apply.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: load_hyphenation.patch
Type: text/x-patch
Size: 747 bytes
Desc: not available
URL: <https://tug.org/pipermail/luatex/attachments/20221105/8b09abd0/attachment.bin>


More information about the luatex mailing list.