Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX: potentially critical low level TeX coding mistake has gone unnoticed so far #8796

Closed
jfbu opened this issue Jan 31, 2021 · 0 comments
Closed

Comments

@jfbu
Copy link
Contributor

jfbu commented Jan 31, 2021

Describe the bug
There is a low-level bug in sphinx.sty:

% box scratch register
\newdimen\spx@image@box
\newcommand*{\sphinxsafeincludegraphics}[2][]{%
% #1 contains possibly width=, height=, but no scale= since 1.8.4
\setbox\spx@image@box\hbox{\includegraphics[#1,draft]{#2}}%

The \spx@image@box it supposed to stand for a box register, but it is defined as a dimension! (\newdimen).

It does not crash the PDF build, because internally when one uses such low-level TeX primitives, the control sequence \spx@image@box is in fact a number. So when one uses it via \setbox\spx@image@box... one will overwrite the contents of the box register with number the one indicated by \spx@image@box. This was a number assigned by \newdimen it should correspond to an available dimension register. It is here used for a box register.

Clearly this could lead to very strange results, very hard to debug, and perhaps has, because a box register gets used which perhaps is also used for other things. As nobody complained PDF output contained garbage there are two explanations:

  • nobody checks PDF output (possibly not far from truth :))
  • as many more \dimen registers are allocated than \box registers the used \box had such a high number no problem came out of it.

The bug was introduced at commit 669f9c3 (#5992) with Sphinx 2.0

@jfbu jfbu added this to the 3.4.4 milestone Jan 31, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant