[NTG-context] handle_error_hook in LuaMetaTeX

Marcel Fabian Kr├╝ger tex at 2krueger.de
Fri Jul 31 18:17:51 CEST 2020


Hi,

thanks for handling
f file consition in LuaMetaTeX. While playing with that, I encountered a
potential bug in the latest LuaMetaTeX version: If handle_error_hook is
executed and returns any number, LuaMetaTeX segfaults. (I'm pretty sure
that this still worked with the previous version) Minimal ConTeXt
example:

\enabledirectives[system.quitonerror=false]
\directlua{
  print(callbacks.register('handle_error_hook', function(...)
    return 3
  end))
}
\undefined % Trigger an error
\starttext
\stoptext

This triggers

[...]
system          > ConTeXt  ver: 2020.07.31 10:20 LMTX  fmt: 2020.7.31  int: english/english
[...]
tex error       > tex error on line 7 in file ./test_empty_input.tex: ! Undefined control sequence

l.7 \undefined
[...]
 9     \stoptext

segmentation fault (core dumped)  /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex    cont-yes.mkiv 

valgrind suggests that this is caused by an attempt to access a null
pointer:

==382632== Invalid write of size 4
==382632==    at 0x1A581F: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x1A662F: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x14BAA8: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x1DA50E: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x1DA802: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x15F956: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x156E2E: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x121E97: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x4A16001: (below main) (in /usr/lib/libc-2.31.so)
==382632==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==382632== 
==382632== 
==382632== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==382632==  Access not within mapped region at address 0x0
==382632==    at 0x1A581F: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x1A662F: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x14BAA8: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x1DA50E: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x1DA802: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x15F956: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x156E2E: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x121E97: ??? (in /home/marcel/lmtx-install/tex/texmf-linux-64/bin/luametatex)
==382632==    by 0x4A16001: (below main) (in /usr/lib/libc-2.31.so)

That me know if you are interested in the coredump.

Best regards,
Marcel


More information about the ntg-context mailing list