<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 5 Nov 2022 at 16:29, Michal Vlasák <<a href="mailto:lahcim8@gmail.com">lahcim8@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu Sep 29, 2022 at 11:58 PM CEST, Werner LEMBERG wrote:<br>
><br>
> Please unpack the attached tarball and call `./zzz.sh`. On my<br>
> openSUSE box using a current SVN version of TeXLive, this crashes with<br>
> a segfault.<br>
<br>
I think I found the issue and have a fix (attached). (Hans CC'd: I<br>
believe this also applies to LuaMetaTeX.)<br>
<br>
The segfaults are in the calls to Lua C API from the function<br>
`load_hyphenation`, which gets called as a result of `\hyphenation`. The<br>
issue is that before pushing to the Lua stack one has to make sure there<br>
is enough free space there (by calling `lua_checkstack`) -- in this case<br>
`load_hyphenation` pushes at most 3 values to the stack. Reserving the<br>
space on the stack should fix the issue.<br>
<br>
But I am fairly sure that the stack would (usually) have at least the 3<br>
needed free slots -- after all LuaTeX doesn't reserve stack space too<br>
often, and other things work just fine. This unveiled another problem:<br>
`load_hyphenation` never pops the table it appends to, so many calls to<br>
it slowly exhaust the stack. A call to `lua_pop` is needed at the end.<br>
<br>
Patch that adds `lua_checkstack` and `lua_pop` is attached.<br>
<br>
Note that the issue exhibits itself so severely because the file<br>
`hyphenation.texi` does `\hyphenation` for each word separately, this is<br>
less efficient and unnecessary, when `\hyphenation` can process many<br>
words just fine.<br>
<br>
<br>
Michal<br>
<br>
<br>
PS: I performed the analysis on a slightly older version of LuaTeX and<br>
in a different build environment, though I think the analysis and<br>
conclusions still apply.<br></blockquote><div><br></div><div>Thank you very much, I will check your patch this evening very carefully.</div><div>I know that there was an issue with the lua stack but I was not able to catch it </div><div>due to the lack of the time and the migrations of the svn repos. </div><div>Anyway, if it's ok I will commit it to the texlive svn repo.</div><div><br></div><div><br></div><div>--</div><div>luigi</div><div> </div></div></div>