mgieseki / dvisvgm

A fast DVI, EPS, and PDF to SVG converter
https://dvisvgm.de
GNU General Public License v3.0
312 stars 34 forks source link

Core dumped (and missing glyphs) #242

Closed soficshift closed 1 year ago

soficshift commented 1 year ago

dvisvgm used to work flawlessly for me just a few months ago, but it seems that after some system updates (or something else) it is throwing core dumps in my system. Worse still, the core dumps are somewhat non deterministic: only some PDF files are problematic (they were not before), and even for the problematic ones sometimes no error is thrown but a blank 0x0 SVG is produced.

➜  dvisvgm -P -n problem2.pdf 
processing PDF file
/usr/include/c++/13/bits/stl_vector.h:1123: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = char; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
[1]    264534 IOT instruction (core dumped)  dvisvgm -P -n problem2.pdf

➜  dvisvgm -P -n problem2.pdf
processing PDF file
  graphic size: 0pt x 0pt (0mm x 0mm)
  output written to problem2.svg
1 of 1 page converted in 0.0766878 seconds

I'm running an up-to-date Fedora 38 system with textlive-scheme-full (texlive 2022). I can reproduce the error with both dvisvgm 3.0.4 from the Copr repo and texlive-dvisvgm 3.0.1 from the official repositories. BUT, when I compile from source there are no core dumps, only errors about missing glyphs (and thus missing text in the generated SVG):

➜  dvisvgm3.0.4 -P -n problem2.pdf
processing PDF file
  ERROR: can't load glyph 13
  ERROR: can't load glyph 1270
  ERROR: can't load glyph 1271
  ERROR: can't load glyph 1272
  ERROR: can't load glyph 1273
  ERROR: can't load glyph 1274
  ERROR: can't load glyph 1275
  graphic size: 337.901396pt x 39.295809pt (118.758758mm x 
  13.810897mm)
  output written to problem2.svg
1 of 1 page converted in 0.11591 seconds

I'm not sure if the missing glyphs is a separate issue or if there is something wrong on my system that causes both, because I used to convert those same PDF files to SVG with no missing glyphs before, and the fonts are just the default LaTeX fonts. I attached a strace report but I don't know how to read it properly. Here are the PDFs for reference:

Core dumps (and missing glyphs with dvisvgm compiled from source): problem1.pdf problem2.pdf problem3.pdf

No core dumps (but missing glyphs): noproblem1.pdf noproblem2.pdf

Core dump strace: https://gist.github.com/lucasvreis/7e77427e2a69887612e6fabd54113f2b

soficshift commented 1 year ago

A small update: I recompiled all my files with dvilualatex, and for dvi everything works very fine with no core dumps nor missing glyphs (in fact, I think I'll adopt DVI for my setup as it seems more stable than PDF!). I'll leave this open since the issue with PDFs is still there, and I can provide more information if necessary, but feel free to close it if you wish.

mgieseki commented 1 year ago

Thank you for reporting these issues. There are actually two bugs involved. Both are related to dvisvgm's new PDF handler which is now used on your system probably because Ghostscript was updated to 10.01.1. Some further information about this can be found here.

I've fixed both bugs and will commit the patches shortly. Nonetheless, dvisvgm's DVI functionality is much more reliable than the PDF one, so it's a good idea to prefer DVI files if possible.