# Using tex.get luatex function (segfault on Linux)?

Looking at LuaTEX Reference Manual (luatexref-t.pdf), it says:

4.13.1 Internal parameter values
For all the parameters in this section, it is possible to access them directly using their names as index in the tex table, or by using one of the functions tex.get() and tex.set().
...
4.13.1.1 Integer parameters
The integer parameters accept and return Lua numbers.
...

Ok, so I want to try tex.get - and I was grepping through my texlive installation looking for examples of its use, but no dice. So, I try a little test with whatever I can come up myself, but it segfaults on my machine (using Texlive 2011 updated to frozen version, Ubuntu 10.04); here is the MWE, compiled with lualatex test.tex:

\documentclass[12pt]{article}

\begin{document}

% this prints tex.get: nil / 1073741823
\directlua{print(""); print("tex.get: " .. tostring(tex.get(boxmaxdepth)) .. " / " .. tex.boxmaxdepth)}

% this segfaults:
% \directlua{print(""); print("tex.get: " .. tostring(tex.get("boxmaxdepth")) ) }

% this segfaults:
% \directlua{print(""); local tgp="boxmaxdepth"; print("tex.get: " .. tostring(tex.get(tgp)) )} % segfault

\end{document}


The strange thing is - tex.boxmaxdepth does indeed return something, and as per manual, so should tex.get("boxmaxdepth"); but any time I try to assign "boxmaxdepth" as a string, either directly or through a variable, I get a segfault - only way I don't get a segfault, is if I pass boxmaxdepth without quotation marks; which means its being interpreted by lua as a variable, which at that point is not set, and thus nil (_NB: first time I see a case where a null variable is the only way you don't get a segfault?! :) _)

Anyways - I hope it's something me not understanding the tex.get syntax, rather than this being a bug; so hopefully someone can clarify this for me :)

-
Confirmed with the latest luatex from svn. Please open a bug report at the LuaTeX bug tracker. – Martin Schröder May 27 '12 at 15:15
workaround: use tex.boxmaxdepth directly. – Taco Hoekwater May 29 '12 at 9:15
@TacoHoekwater The segfault seems to occur from __index and get is just a wrapper. The code faults due to an comparison with "4" and an invalid pointer. In any case I come to this bug trying use get on "interactionmode". – AbstractDissonance Jul 16 '12 at 10:45