open/import clicking on a 0 byte image results in a crash

Bug #168471 reported by Amphi-users
2
Affects Status Importance Assigned to Milestone
Inkscape
Confirmed
Critical
Ishmal

Bug Description

In the File->open or File->import dialog... click on a 0 byte image (tried
png, bmp and jpg) and Inkscape will instantaneously crash.

0.45 and the 0703040005 snapshot on win2k.

Revision history for this message
Horkana-users (horkana-users) wrote :

Originator: NO

Dammit! Wish I'd thought of that, I've crashed loads of programs this way.

Nice catch.

There is an old tradition of using touch to create an empty file with the
name you want and then opening it and letting the program create the rest
of the file. surprising no one ever tripped over this before.

Bumping priority slightly. This is probably something that needs to be
corrected in the file import code in various places throughout inkscape.

Revision history for this message
Buliabyak-users (buliabyak-users) wrote :

Originator: NO

confirmed with latest build on winxp

ishmal can you please have a look what we are doing wrong

Revision history for this message
Johan Engelen (johanengelen) wrote :

Originator: NO

GDB mentions: terminate called after throwing an instance of
'Gdk::PixbufError'

Revision history for this message
Johan Engelen (johanengelen) wrote :

Originator: NO

I have found the location of the bug, but for some reason the standard fix
won't work. I am very much confused. The crash happens in
ui/dialog/filedialogimpl-gtkmm.cpp, function SVGPreview::showImage on the
call "img = Gdk::Pixbuf::create_from_file(fileName);".

I've changed the code to the following:
    Glib::RefPtr<Gdk::Pixbuf> img(NULL);
    try {
        img = Gdk::Pixbuf::create_from_file(fileName);
    }
    catch (Glib::FileError e)
    {
        g_message("caught Glib::FileError in SVGPreview::showImage");
        return;
    }
    catch (Gdk::PixbufError e)
    {
        g_message("Gdk::PixbufError in SVGPreview::showImage");
        return;
    }

But for some reason, *still* the Gdk::PixbufError exception is not caught.
Also catch(...) will not catch it, and the application keeps saying that
'Gdk::PixbufError' is not caught.
What's happening?

Revision history for this message
Amphi-users (amphi-users) wrote :

Originator: YES

Opening an SVG file which references a 0 byte sized image or a completely
malformed image appears to be fine. In both cases the "Linked Image not
found" placeholder is shown.

By the looks of it only the open dialog (which shows some preview) is
affected. Interestingly it still crashes on click if the preview is
disabled. This happens in both cases; 0 bytes and random text (saved as
JPG).

Revision history for this message
pbhj (pbhj) wrote :

Originator: NO

I just get "Failed to load the requested file
/home/user/Desktop/test.svg"

In the console I see (between the ---):

---
** (inkscape:21461): WARNING **: SVGView: error loading document
'/home/pandfi/Desktop/test.svg'

/home/pandfi/Desktop/test.svg:1: parser error : Document is empty

^
/home/pandfi/Desktop/test.svg:1: parser error : Start tag expected, '<'
not found
---

Revision history for this message
Amphi-users (amphi-users) wrote :

Originator: YES

Yes, 0 byte SVGs are fine. I meant bitmaps with "images".

Revision history for this message
Johan Engelen (johanengelen) wrote :

Originator: NO

    try {
        throw Gdk::PixbufError(NULL); // <---- new code
        img = Gdk::Pixbuf::create_from_file(fileName);
    }
    catch (Gdk::PixbufError e)
    {
        g_message("Gdk::PixbufError in SVGPreview::showImage");
        return;
    }

This does trigger the catcher. So the catcher works.

Revision history for this message
Johan Engelen (johanengelen) wrote :

Originator: NO

I have this uncatched exception on linux aswell. But others don't...

Revision history for this message
Dvlierop2 (dvlierop2) wrote :

Originator: NO

When I click on the file in the file-open dialog, I get:
     ** Message: Gdk::PixbufError in SVGPreview::showImage

When I subsequently open the file, I get this:
     ** Message: error loading pixbuf at close
     GdkPixbuf loader failed

When I try to add a rectangle to the file, Inkscape crashes with:
     ** ERROR **: file document-undo.cpp: line 171 (void
sp_document_maybe_done(SPDocument*, const gchar*, unsigned int,
Glib::ustring)): assertion failed: (doc->priv->sensitive)
     aborting...

This is when using rev. 16441 on Fedora. I hope this is of any use....

Bryce Harrington (bryce)
Changed in inkscape:
status: New → Confirmed
Revision history for this message
theAdib (theadib) wrote :

I have marked this bug as duplicate to one where exceptions not caugth. This happens on the mingw 4 series compiler.
The issue is that there is a need for a special flag to throw exceptions accross dll boundaries.
We either need to solve the mingw gcc 4 issue or switch back to version 3.
HTH, Adib.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.