inkscape crashes on import of (corrupted) PNG

Bug #271401 reported by Christian Wäckerlin on 2008-09-17
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Krzysztof Kosinski
Nominated for 0.48.x by Krzysztof Kosinski

Bug Description


when I import the attached PNG file, Inkscape crashes.

I use 0.46-2 form Debian/testing on i386.

Please note that the PNG file is corrupted, but it should not crash anyway.


Christian Wäckerlin

0xb7ef2424 in __kernel_vsyscall ()
(gdb) bt
#0 0xb7ef2424 in __kernel_vsyscall ()
#1 0xb6728640 in raise () from /lib/i686/cmov/
#2 0xb672a018 in abort () from /lib/i686/cmov/
#3 0xb72fa7b7 in png_create_read_struct_2 () from /usr/lib/
#4 0x00000000 in ?? ()

Related branches

tags: added: import-export
bbyak (buliabyak) on 2009-08-19
Changed in inkscape:
status: New → Confirmed
importance: Undecided → High
tags: added: crash
hyperqbe (hyperqbe) wrote :

Attaching patch (applies to inkscape-0.47~pre4, but I'm sure it's simple enough to paste the code into any version).

The problem is that libpng uses setjmp/longjmp for error handling. Inkscape was not calling setjmp, so libpng was taking the default method of handling errors: abort.

This is my first inkscape patch and I am unfamiliar with the codebase, so please check it over.

Changed in inkscape:
assignee: nobody → Krzysztof Kosiński (tweenk)
status: Confirmed → Fix Committed
su_v (suv-lp) wrote :

1) Compiling 0.47+devel r9040 on OS X 10.5.8 I get these warnings:

  CXX sp-image.o
sp-image.cpp: In function ‘GdkPixbuf* Inkscape::IO::pixbuf_new_from_file(const char*, time_t&, gchar*&, GError**)’:
sp-image.cpp:269: warning: variable ‘dpiX’ might be clobbered by ‘longjmp’ or ‘vfork’
sp-image.cpp:270: warning: variable ‘dpiY’ might be clobbered by ‘longjmp’ or ‘vfork’

2) The patch works, nevertheless: when trying to import the corrupted image 'content.png' (attached to comment #1) Inkscape 0.47+devel r9040 refuses to load the image (whereas Inkscape 0.47 r22583 on osx does crash).

Console messages from Inkscape 0.47+devel r9040:

** Message: Gdk::PixbufError in SVGPreview::showImage
libpng warning: Ignoring bad adaptive filter type
libpng error: IDAT: CRC error
GdkPixbuf loader failed

Krzysztof Kosinski (tweenk) wrote :

The warnings look spurious, because those variables are not used after longjmp, but maybe they are fixable.

jazzynico (jazzynico) on 2010-02-15
Changed in inkscape:
milestone: none → 0.48
Jon A. Cruz (jon-joncruz) wrote :

From the man page on setjmp.

"setjmp() and sigsetjmp() make programs hard to understand and maintain. If possible an alternative should be used."

Depending on whether or not some debugging is going to be done, those might be. But as long as there is not an alternative to the setjmp() use, you are right that some restructuring should clean up the issue.

Jon A. Cruz (jon-joncruz) wrote :

Revision 9196 was committed with changes to cleanup the setjmp() use and avoid the early return. One side effect of the cleanup is that the gdk pixbuf loader is now allowed to partially load malformed images, consistent with other applications such as eog.

Not sure if the compile warnings some see on clobbering are completely fixed by this, but should be closer.

su_v (suv-lp) wrote :

> gdk pixbuf loader is now allowed to partially load malformed
> images, consistent with other applications such as eog.

confirmed with 'content.png' from comment #1: it is loaded and partially rendered after importing it (both if linked or embedded) (tested with Inkscape 0.47+devel r9196 on OS X 10.5.8).
Is it possible to do the same for the thumbnail preview in the gtkfilechooser dialog?

> Not sure if the compile warnings some see on clobbering are
> completely fixed by this

no more warnings seen for sp-image.o when compiling with
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)

su_v (suv-lp) wrote :

@JonCruz - Inkscape 0.47+devel r9196 on OS X 10.5.8 no longer previews and loads correct JPEG and TIFF images (and possibly other formats) - displaying the 'Linked image not found' placeholder instead. Only PNG files load without error.

Checked against r9195 which previews and loads the same uncorrupted JPEG and TIFF images without error.

Jon A. Cruz (jon-joncruz) wrote :

Should be corrected in rev 9197

jazzynico (jazzynico) on 2010-08-24
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Related blueprints

Bug attachments