pts / sam2p

raster (bitmap) image converter with smart PDF and PostScript (EPS) output
http://pts.50.hu/sam2p/
GNU General Public License v2.0
42 stars 15 forks source link

crashes in 2018-07-sam2p-crashes.zip #46

Closed pts closed 6 years ago

pts commented 6 years ago

This file contains some test input files for which sam2p crashes 2018-07-sam2p-crashes.zip.

pts commented 6 years ago

@fgeek, you may be interested in this issue.

pts commented 6 years ago

I'm trying the input files in 2018-07-sam2p-crashes.zip with sam2p at commit 3eea9c499977ffd9da64ca9ad0967706a5b26004 on architecture amd64, compiled with gcc-7.3 on Linux:

For many of the input files sam2p succeeds.

For example, sample-62 (and many other input files) have caused this failure:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted

This indicates an out-of-memory error. It is possible to make this error message friendlier (e.g. Image too large for sam2p, would need at least +... GiB of memory to process it), but it would be too much work right now (because all memory allocation locations would have to be changed). Feel free to file a separate issue if this error message improvement is needed.

For example, sample-33 (and many other input files) has caused a failure with a friendly error message:

sam2p.no: Error: PNM: error reading file

sample-109 has caused a failure with a friendly error message:

sam2p.no: Error: PNM: inconsistent width or height in alpha

possible-dos-001.gif has caused a failure with a friendly error message:

sam2p.no: Error: PNM: premature end of file

When trying the same input files ASAN enabled (make sam2p.yes GFLAG='-ggdb -fsanitize=address'), the same failures happen for the same files, but the actual error message on an out-of-memory error looks different, e.g.

This is sam2p 0.49.4.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
==107046==WARNING: AddressSanitizer failed to allocate 0x1b02ffe7d659 bytes
==107046==AddressSanitizer's allocator is terminating the process instead of returning 0
==107046==If you don't like this behavior set allocator_may_return_null=1

When trying the same input files with uClibc (compile_xstatic.sh) on architecture i386:

For example, sample-86 (and many other input files) has caused this failure:

sam2p.xstatic.uncompressed: Error: Image: Image too large.

For example, sample-74 (and many other input files) has caused this failure:

sam2p.xstatic.uncompressed: Error: PNM: can't open file   

This error message is misleading (because the file can be opened successfully), I've committed 67499e38a7a0faedee2b46fcc5a559d977eb71bd to fix it, now the error message is:

sam2p.xstatic.uncompressed: Error: PNM: Image too large.

sample-109 has caused a failure with a friendly error message:

sam2p.xstatic.uncompressed: Error: PNM: inconsistent width or height in alpha

As of now, I can see only inaccurate error messages, but no crashes or other misbehavior. @fgeek, is your experience the same for these inputs?

pts commented 6 years ago

@fgeek, feel free to rerun sam2p at HEAD or at commit 67499e38a7a0faedee2b46fcc5a559d977eb71bd, and if you experience any misbehavior (other than out-of-memory errors and the error messages reported above), please comment on this issue, and I'll reopen it.