holzschu / lib-tex

pdftex and luatex as a library. Developped for iOS, but should work on all systems.
72 stars 8 forks source link

Can't compile twice #1

Open izmishi opened 4 years ago

izmishi commented 4 years ago

It can compile a tex file once, but when I try to compile a tex file after that, the app I'm using it in crashes and I get the following error

!pdfTeX error: pdflatex: zlib: deflateReset() failed (error code -2)

The minimal TeX file this happens with is

\documentclass{article}
\begin{document}
Any text
\end{document}

I also can't get lualatex to work.

private/var/mobile/Containers/Data/Application/550319A1-DF62-4773-BBCE-FB24AD
A1D234/Library/texlive/2019/texmf-dist/tex/latex/base/size10.clo
! Font \TU/lmr/m/n/10=[lmroman10-regular]:+tlig; at 10pt not loadable: metric d
ata not found or bad.
<to be read again> 
relax 
l.54 \normalsize

? 
! Emergency stop.
<to be read again> 
relax 
l.54 \normalsize

 276 words of node memory still in use:
   1 dir, 3 kern, 1 glyph, 1 attribute, 35 glue_spec, 1 attribute_list, 2 if_st
ack nodes
   avail lists: 2:8,3:1,4:1,5:1
!  ==> Fatal error occurred, no output PDF file produced!
holzschu commented 4 years ago

I have trouble reproducing this issue. Small files and long files work, for multiple compilations.

There must be something subtly different between our configurations. I will probably need more information to solve this.

Maybe the full log files contain more information (Xcode and TeX)? I think you can attach documents to a message.

izmishi commented 4 years ago

Apologies for the delay.

I've done some digging and found that pdftex uses zlib to compress the stream. I think setting \pdfcompresslevel=0 means that zlib won't be used (since we are asking for no compression). So I have two test files, Compression.tex and No Compression.tex, which are minimal files that differ only by the presence/absence of the line \pdfcompresslevel=0.

Method Used

  1. Launch app
  2. Try to compile Compression.tex as many times as possible
  3. Close and re-launch app (to start from a fresh state)
  4. Try to compile No Compression.tex as many times as possible

Compression.tex

1st compilation

As expected, a PDF is produced. The log file produced is found at Compression Compile 1.log.

2nd compilation

Failed to produce a PDF and the log file is empty (0 KB). I managed to capture the stdout, which can be found at Compression Compile 2 stdout.log.

3rd compilation

Failed to produce a PDF but did produce a non-empty log file which can be found at Compression Compile 3.log.

4th compilation

Same as 2nd compilation. The captured stdout can be found at Compression Compile 4 stdout.log.

5th compilation

Same as 3rd compilation. The produced log file can be found at Compression Compile 5.log.

Subsequent compilations

Followed the pattern in the 2nd-5th compilations, no PDF produced and it kept switching between producing a 0 KB log file and a full log file.

No Compression.tex

1st compilation

As expected, a PDF is produced. The log file produced is found at No Compression Compile 1.log.

2nd compilation

Crashed the app with a SIGABRT. The backtrace can be found at No Compression Compile 2 bt.txt. A damaged PDF and a log file were produced; these can be found at No Compression Compile 2.pdf and No Compression Compile 2.log. The stdout can be found at No Compression Compile 2 stdout.log.

Everything should be in the zip file attached lib-tex Issues.zip

holzschu commented 4 years ago

Thanks for that detailed report. I'm going to have a look.

holzschu commented 4 years ago

On a-Shell, which uses the latest version of lib-tex, I can compile pdflatex Compression.tex and pdflatex No\ Compression.tex multiple times, with no crash. Each run produces a valid PDF file and a log file.

I am going to have a look at your logs, but the mistery deepens.