bugGNU Octave - Bugs: bug #38166, crash when printing with no output...


bug #38166: crash when printing with no output file (i.e. spooling via lpr)

Submitted by:  Mark van Rossum <cosine>
Submitted on:  Fri Jan 25 11:12:58 2013  
Category: Plotting with gnuplotSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Segfault, Bus Error, etc.
Status: FixedAssigned to: Ben Abbott <bpabbott>
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Thu Sep 5 23:48:03 2013, comment #13:



Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Thu Sep 5 21:37:31 2013, comment #12:

Everything seems hunky-dory with the latest changeset. Commit it!

Rik <rik5>
Project Administrator
Thu Sep 5 18:47:10 2013, comment #11:

Ok. I've added some additional checking on the inputs. New changeset it attached.

(file #29018)

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Thu Sep 5 15:26:24 2013, comment #10:

With your new changeset I no longer get any crashes. However, when I use a format that is not a match for "case opts.ghostscript.device" I get a file in the current directory named '-'. I think this was meant to go to stdout, or maybe to lpr, rather than to the file '-'.

Separate issue, when I test the case branch that begins with epslatex I get

Given that this branch needs to create two files, NAME.tex and NAME.eps, we should probably just issue an error if the filename is null because we don't want to send both files to the printer.

Rik <rik5>
Project Administrator
Thu Sep 5 12:08:20 2013, comment #9:

Thanks Rik,

I've attached a new changeset with the ghostscript pipe setup in _print_parse_opts_.m

(file #29015)

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Thu Sep 5 02:52:20 2013, comment #8:

Ben, I just tried your patch and I still get a segfault on a linux system with gnuplot toolkit.

After some debugging, it appears to be because we call eps_drawnow with a filename of "" from within _gnuplot_drawnow_.m. I added a line to set it in the ".eps" branch of the case statement and it doesn't crash anymore. But, this isn't my area so you should probably take a look at it. (See attached eps.crash.patch) In particular, the code doesn't send anything to the printer, but maybe that is right.

Test code

Note, that it is still possible to get Octave to segfault by using one of the other branches of the case statement such as

This suggests that we should really move the test for a null opts.name above the case statement so it can apply to everyone.

(file #29009)

Rik <rik5>
Project Administrator
Thu Sep 5 00:31:20 2013, comment #7:

I've attached a changeset that works for me. I'll run some more tests and push if I don't find any regressions.

I am unable to test a Windows build. Can someone else do that?

(file #29008)

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Tue Sep 3 01:29:18 2013, comment #6:

I haven't confirmed, but the problem looks to be that the "-sOutputFile=-" isn't included in the ghostscript options.


For Unix or Windows the proper pipeline would be,

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Sat Aug 31 20:44:26 2013, comment #5:

In the absence of a file name, the print command produces a temporary file which is spooled to the system a printer via lpr. Using the "-debug" will provide information for debugging what goes wrong (the print command works for me on MacOSX)

For Gnuplot ...

For FLTK ...

The diff below will provide more info for debugging.

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Wed Jan 30 23:16:37 2013, comment #4:

You're right, this bug only happens with gnuplot (MinGW + MSVC on Windows) - can't test Linux ATM.

To invoke fltk: in Octave, type

graphics_toolkit fltk

and try again.

Philip Nienhuis <philipnienhuis>
Project Member
Wed Jan 30 19:42:59 2013, comment #3:

I see this with gnuplot on linux, not sure how use fltk.

Mark van Rossum <cosine>
Wed Jan 30 16:23:21 2013, comment #2:

Just to help narrow this down, I get this crash only when using gnuplot as the plotting backend. When using FLTK the postscript output is sent to the screen (still not right). Is this behavior also seen by the original bug reporter?

Rik <rik5>
Project Administrator
Sat Jan 26 22:24:47 2013, comment #1:

Confirmed in dev version and 3.6.1 on Linux.

Interestingly, this works OK on Windows w. 3.6.1 & 3.6.2 (MinGW & MSVC); that is, all the output meant for the graphical backend is echoed to the Octave terminal (I have no opinion on whether that is expected or Good behavior) but there's no crash.

Philip Nienhuis <philipnienhuis>
Project Member
Fri Jan 25 11:12:58 2013, original submission:

If I do
plot(1); print -deps

Octave crashes with
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr
panic: Aborted -- stopping myself...

This is -incorrect- use, as a file name should follow the print command.
Nevertheless, a somewhat less dramatic response would be nice.

Mark van Rossum <cosine>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #29018:  changeset.patch added by bpabbott (1kB - application/octet-stream)
file #29015:  changeset.patch added by bpabbott (867B - application/octet-stream)
file #29009:  eps.crash.patch added by rik5 (1kB - application/x-download)
file #29008:  changeset.patch added by bpabbott (1kB - application/octet-stream)


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -unavailable- added by bpabbott (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by philipnienhuis (Posted a comment)
  • -unavailable- added by cosine (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 13 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Sep 5 23:48:03 2013bpabbottStatusConfirmed=>Fixed
    Thu Sep 5 18:47:10 2013bpabbottAttached File-=>Added changeset.patch, #29018
    Thu Sep 5 12:08:20 2013bpabbottAttached File-=>Added changeset.patch, #29015
    Thu Sep 5 02:52:20 2013rik5Attached File-=>Added eps.crash.patch, #29009
    Thu Sep 5 00:31:20 2013bpabbottAttached File-=>Added changeset.patch, #29008
      Assigned toNone=>bpabbott
    Tue Sep 3 01:29:18 2013bpabbottRelease3.6.3=>dev
      Operating SystemGNU/Linux=>Any
    Sat Aug 31 20:44:26 2013bpabbottSummarycrash on incorrect print command=>crash when printing with no output file (i.e. spooling via lpr)
    Fri May 31 22:40:25 2013mtmillerDependencies-=>bugs #39131 is dependent
    Wed Jan 30 23:37:28 2013rik5CategoryInterpreter=>Plotting with gnuplot
    Sat Jan 26 22:24:47 2013philipnienhuisStatusNone=>Confirmed

    Back to the top

    Powered by Savane 3.1-cleanup1