pdflatex failures on big-endian architectures (s390x / ppc64)

Hilmar Preuße <hille42-S0/[email protected]> Mon, 23 Oct 2023 00:04:24 +0200
Newsgroups gmane.comp.tex.pdftex
Organization Hilmar Preuße Inc.
Message-ID <[email protected]>
Dear pdfTeX developers,

This is rather 1:1 copy of the Debian bug report #1054218. I don't 
attach the original sample files, but rather some minimal examples I 
generated on ppc64. Interestingly the issue does not occur, when using 
plain TeX, I needed to construct a LaTeX example.

Further I got the information, that it worked fine on Debian oldstable, 
meanwhile it does not work since Debian stable. Debian unstable is still 
affected. I did not find anything in 
texlive-source/texk/web2c/pdftexdir/ChangeLog, which points to a bug fix 
for this.

hille@debian-haka2:~$ pdftex --version
pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian)
kpathsea version 6.3.2
Copyright 2020 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.02

Stopped working:

hille@haka2:~$ pdftex --version
pdfTeX 3.141592653-2.6-1.40.24 (TeX Live 2022/Debian)
kpathsea version 6.3.4
Copyright 2022 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.39; using libpng 1.6.39
Compiled with zlib 1.2.13; using zlib 1.2.13
Compiled with xpdf version 4.04


<snip>
The unittests of the 'plastex' package run pdflatex to generate some
figures, and then extract the text from the figures to verify that
various implementation details of the package are working. These tests
pass on all release architectures except s390x. They also fail on ppc64.
The common feature of the failures is that the architecture is
big-endian.

The failures are all similar to:

   AssertionError: 'hi' != '\x00\x00'

i.e. the text that is found in the PDF (either by gs or pdftotext) is
the same number of bytes as the original text, but is all \0. The
extraction is platform-independent — the attached 1054218_ppc64.pdf 
yields \0\0 for its text no matter what arch pdftotext or gs is run on.

The PDFs all _look_ OK in any PDF viewer, it's just the text extraction
that fails.

If the pdf is generated via latex followed by dvipdf then the extracted
text is correct (up to whitespace); if the pdf is generated by lualatex
then he extracted text is correct.

It seems that pdflatex is mishandling embedding the text on big endian
systems. Speculating wildly... it looks a bit like pdflatex is taking
the wrong byte out of a multibyte character representation, and ending
up with \0 rather than the byte of interest, but I don't know how
pdflatex is representing the characters internally or how it is encoding
them into the PDF.

Business impact:
While I don't expect that there are many direct users of pdflatex on 
s390x, testing migration within Debian now requires successful 
completion of unittests on s390x, and so arch-specific bugs on s390x 
become relevant.
<snip>

Hilmar
--
1054218_ppc64.tex (text/x-tex, 99 B)
\AtBeginDocument{\thispagestyle{empty}}
\documentclass{article}
\begin{document}
hi
\end{document}
1054218_ppc64.pdf (application/pdf, 10.9 KB) - not displayed
1054218_amd64.pdf (application/pdf, 10.9 KB) - not displayed
OpenPGP_signature.asc (application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE-----

wsF5BAABCAAjFiEEaXGmC/nkbIhxf16kxiZYRqvgLIsFAmU1nGkFAwAAAAAACgkQxiZYRqvgLIsR
BA/8D9f2ZMbOhFjlVhQfkAeki9TpE6k5pVL4nbPbqaQ8im/VKgRPhy/zBByZkMA/GzdvG7RKRpOc
LKuET1WpOPUrcNTyJIsnsXmryeMl+KjzgAWil1Rc2NNTdFICa6je8Wr2IIz9V4CR+OKGBY34nVxd
hq/WcjMwTA0Qw3Dumk1ClTZajB4F/N/nzA33HV/6DnAS7W/ftaSsxUNJatgOErpdAx70DbQW79I2
liVi0G2Fni5tiYHUx7rdysAB4dXDXxMHHxsTLJu1qzAt+I+ofSBFxMK1J4hipQpDUSJktoOjKCa2
2fLtoMiHDrbd0sNBoxrNLXwAMfhnJvLhMGu1o41AZOBDLlqTQpsQlXrc27KiwTS+amRElXrKHRg6
gPBm6IcgY0eEKvo76izrEK92//lS4ZC7amLduMSV0LLe9j6b0Uz3s+F4tOH/efO/kaQ0CXJP/I8W
h79fDbhukPkjQhyK1TuHkYDng/CSUVvvVHU2UwH/6Dd/WQgingQJWm66QHyWCaZXh2t9m7KFOuSG
oKZ+ZuM6ELL4dvvch9Y1U7q90LigkB/O5W31iqQ4/vUhCFQSMgbxXw32rUPIbmgfWgz+Fi1OErbh
YWCbsT01Opjd0lZ3VgXWo6RBrGyvRPPoyhpXG0RBscDOMQGRCMuj8GMEnnlq1D+t+dJQHQmXy+nK
sxc=
=yFKC
-----END PGP SIGNATURE-----