"--export-png=" assert-fails if given bad argument

Bug #941103 reported by Arthur O'Dwyer
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Low
Martin Owens

Bug Description

Inkscape currently uses a very scary-looking "assertion failed" message to report bad command-line arguments. I expect this is considered a low-priority cosmetic feature, but it would still be nice to do some error-checking and give a friendlier message that doesn't begin with a lot of asterisks, a PID, and the word "CRITICAL" in all caps.

% inkscape "--export-png=" myfile.svg
DPI: 300
Background RRGGBBAA: ffffff00
Area 0:0:247.5:337.5 exported to 825 x 1125 pixels (300 dpi)
Bitmap saved as:
** (inkscape:7189): CRITICAL **: bool sp_png_write_rgba_striped(SPDocument*, const gchar*, long unsigned int, long unsigned int, double, double, int (*)(const guchar**, int, int, void*), void*): assertion `fp != NULL' failed

% inkscape -v
** (inkscape:7234): WARNING **: Invalid option -v

% inkscape --version
Inkscape 0.48.2 r9819 (Jul 11 2011)

Tags: cli crash
Revision history for this message
su_v (suv-lp) wrote :

Reproduced with Inkscape 0.48.2, 0.48.3.1 and 0.48+devel r11016 on OS X 10.7.2.

tags: added: cli
Changed in inkscape:
importance: Undecided → Wishlist
status: New → Confirmed
importance: Wishlist → Low
Revision history for this message
su_v (suv-lp) wrote :

Using '--export-pdf' as bad argument instead of '--export-png' even triggers a real crash:

$ inkscape -V
Inkscape 0.48.2 r9819 (Dec 21 2011)
$ inkscape "--export-pdf=" myfile.svg
inkscape: fopen(): No such file or directoryterminate called throwing an exception
Emergency save activated!
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at www.inkscape.org
with a detailed description of the steps leading to the crash, so we can fix it.
** Message: Error: Inkscape encountered an internal error and will close now.

Abort trap: 6
$
$ inkgcc46 -V
Inkscape 0.48+devel r11016 custom (Feb 25 2012)
$ inkgcc46 "--export-pdf=" myfile.svg
inkscape: fopen(): No such file or directory
terminate called after throwing an instance of 'Inkscape::Extension::Output::save_failed'

Emergency save activated!
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at www.inkscape.org
with a detailed description of the steps leading to the crash, so we can fix it.
** Message: Error: Inkscape encountered an internal error and will close now.

Abort trap: 6
$

tags: added: crash
Revision history for this message
su_v (suv-lp) wrote :

Fixed in trunk rev >= 12972
<http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/12972>

$ inkscape "--export-png=" myfile.svg

** (inkscape:75276): WARNING **: Can't open file: myfile.svg (doesn't exist)

** (inkscape:75276): WARNING **: Can't open file: myfile.svg (doesn't exist)

** (inkscape:75276): WARNING **: Specified document myfile.svg cannot be opened (does not exist or not a valid SVG file)
$
$ inkscape "--export-png=" myfile.pdf
I/O Error: Couldn't open file 'myfile.pdf': No such file or directory.
** Message: couldn't open the PDF file.

** (inkscape:75277): WARNING **: Can't open file: myfile.pdf (doesn't exist)

** (inkscape:75277): WARNING **: Specified document myfile.pdf cannot be opened (does not exist or not a valid SVG file)
$

See also:
<http://article.gmane.org/gmane.comp.graphics.inkscape.devel/42536>

Changed in inkscape:
assignee: nobody → Martin Owens (doctormo)
milestone: none → 0.91
status: Confirmed → Fix Committed
Changed in inkscape:
status: Fix Committed → Confirmed
Revision history for this message
Arthur O'Dwyer (arthur-j-odwyer) wrote :

Sorry, but from the above output and looking at the source code touched in r12972, it doesn't *look* like anything relevant was fixed. (Feel free to re-close this bug with an appropriate summary if the bug is actually fixed, but please test it first.)

~suv, notice that in your cut-and-pasted error output, you're not triggering the assertion codepath. The error messages you're getting are because you've given *input* filenames which don't exist. The reported assertion-failure happens when the *output* file cannot be created. Create your input files first, *then* try the supplied command lines.

(BTW, it's also weird that a single missing input file gave you *three* error messages on stderr. Surely there's some UX work to be done in that area.)

Revision history for this message
su_v (suv-lp) wrote :

@Arthur - you are correct (my test was bogus, and the issue as reported is not fixed). Sorry for the noise!

Changed in inkscape:
assignee: Martin Owens (doctormo) → nobody
milestone: 0.91 → none
Revision history for this message
su_v (suv-lp) wrote :

For the sake of completeness, here's the output of the correct test with latest build:

$ inkscape -V
Inkscape 0.48+devel r12980 (Jan 26 2014)
$ ll drawing.svg
-rw-r--r-- 1 su_v staff 1742 Dec 7 11:04 drawing.svg
$ inkscape "--export-png=" drawing.svg
Background RRGGBBAA: ffffff00
Area 0:0:744.094:1052.36 exported to 744 x 1052 pixels (90 dpi)
Bitmap saved as:

** (inkscape:41856): CRITICAL **: bool sp_png_write_rgba_striped(SPDocument*, const gchar*, long unsigned int, long unsigned int, double, double, int (*)(const guchar**, void**, int, int, void*), void*): assertion 'fp != NULL' failed
$

Revision history for this message
Martin Owens (doctormo) wrote :

I was super excited to have a serendipitous bug close. Alas, this requires a real fix:

So, please see r12981 where I've protected png, pdf(ps/eps), wmf and emf exports from the command line.

Changed in inkscape:
assignee: nobody → Martin Owens (doctormo)
status: Confirmed → Fix Committed
Revision history for this message
Arthur O'Dwyer (arthur-j-odwyer) wrote :

Oh my god. You guys. :P

Shall I open a new bug report for the still-broken case of

inkscape --export-pdf=. myfile.svg

or shall I just give up in despair?

Look, the assertion failure is very specific. Inkscape assert-fails if it gets into sp_png_write_rgba_striped() with fp == NULL. If you don't fix that assertion failure, then this bug hasn't been fixed yet.

Revision history for this message
Martin Owens (doctormo) wrote :

See r12982. Which catches the actual errors and outputs a warning.

Revision history for this message
Arthur O'Dwyer (arthur-j-odwyer) wrote :

Well, that patch at least seems plausible. It probably doesn't deal with ~suv's export-pdf example, but at this point it's close enough for horseshoes and/or government work. I don't mind if you want to call it closed.

Revision history for this message
su_v (suv-lp) wrote :

> inkscape --export-pdf=. myfile.svg

Nit-picking:

$ inkscape --export-ps=. drawing.svg
$ inkscape --export-eps=. drawing.svg

r12982 reports failure for 'pdf' even if the user attempted to export to PostScript or EPS

$ inkscape --export-emf=. drawing.svg
$ inkscape --export-wmf=. drawing.svg

Other file formats: emf/wmf export still crashes with '.' as output file name - probably better handled in a separate report. And then there are more formats pending to be added as command line option (e.g. odg - bug #201614).

su_v (suv-lp)
Changed in inkscape:
milestone: none → 0.91
status: Fix Committed → Fix Released
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.