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)

Submitter:  Mark van Rossum <cosine>
Submitted:  Fri 25 Jan 2013 11:12:58 AM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  bpabbott
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 05 Sep 2013 11:48:03 PM UTC, comment #13: 
Ben Abbott <bpabbott>
Group Member
Thu 05 Sep 2013 09:37:31 PM UTC, comment #12: 

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

Rik <rik5>
Group administrator
Thu 05 Sep 2013 06:47:10 PM UTC, comment #11: 

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

(file #29018)

Ben Abbott <bpabbott>
Group Member
Thu 05 Sep 2013 03:26:24 PM UTC, 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


error: 'name' undefined near line 96 column 30
error: evaluating argument list element number 1
error: evaluating argument list element number 2
error: called from:
error:   /home/rik/wip/Projects_Mine/octave-dev/scripts/plot/private/__gnuplot_print__.m at line 95, column 7
error:   /home/rik/wip/Projects_Mine/octave-dev/scripts/plot/print.m at line 415, column 14


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>
Group administrator
Thu 05 Sep 2013 12:08:20 PM UTC, 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>
Group Member
Thu 05 Sep 2013 02:52:20 AM UTC, comment #8: 

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


octave:5> print -deps
warning: print.m: fig2dev binary is not available.
Some output formats are not available.
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr
Abort


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


graphics_toolkit gnuplot;
plot (1:10);
print -deps


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


print -dsvg


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>
Group administrator
Thu 05 Sep 2013 12:31:20 AM UTC, 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>
Group Member
Tue 03 Sep 2013 01:29:18 AM UTC, comment #6: 

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

http://www.ghostscript.com/doc/current/Use.htm#Pipes

For Unix or Windows the proper pipeline would be,


gnuplot-pipeline: '/opt/local/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -dLanguageLevel=1 -dEmbedAllFonts=true -dEPSCrop -sPAPERSIZE=letter -dFIXEDMEDIA -sOutputFile=- /var/tmp/oct-YP9zhA.ps /var/tmp/oct-noAx1s.eps | /usr/bin/lpr -l ; rm /var/tmp/oct-noAx1s.eps ; rm /var/tmp/oct-YP9zhA.ps'


Ben Abbott <bpabbott>
Group Member
Sat 31 Aug 2013 08:44:26 PM UTC, 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 ...


print -dpsc -debug
GPL Ghostscript 9.06: **** Could not open the file  .
---- begin /var/tmp/oct-YP9zhA.ps ----
%!PS-Adobe-3.0
<< /Margins [0 0] /.HWMargins [0 0 0 0] /PageOffset [18 180] >> setpagedevice
%%EOF
----- end /var/tmp/oct-YP9zhA.ps -----
Ghostscript command: '/opt/local/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -dLanguageLevel=1 -dEmbedAllFonts=true -dEPSCrop -sPAPERSIZE=letter -dFIXEDMEDIA /var/tmp/oct-YP9zhA.ps /var/tmp/oct-noAx1s.eps'
lpr command: '/usr/bin/lpr -l'
gnuplot-pipeline: '/opt/local/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -dLanguageLevel=1 -dEmbedAllFonts=true -dEPSCrop -sPAPERSIZE=letter -dFIXEDMEDIA /var/tmp/oct-YP9zhA.ps /var/tmp/oct-noAx1s.eps | /usr/bin/lpr -l ; rm /var/tmp/oct-noAx1s.eps ; rm /var/tmp/oct-YP9zhA.ps'


For FLTK ...


print -dpsc -debug
---- begin /var/tmp/oct-IYbcMv.ps ----
%!PS-Adobe-3.0
<< /Margins [0 0] /.HWMargins [0 0 0 0] /PageOffset [18 180] >> setpagedevice
%%EOF
----- end /var/tmp/oct-IYbcMv.ps -----
Ghostscript command: '/opt/local/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -dLanguageLevel=1 -dEmbedAllFonts=true -dEPSCrop -sPAPERSIZE=letter -dFIXEDMEDIA -sOutputFile="-" /var/tmp/oct-IYbcMv.ps -'
lpr command: '/usr/bin/lpr -l'
fltk-pipeline: '/opt/local/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -dLanguageLevel=1 -dEmbedAllFonts=true -dEPSCrop -sPAPERSIZE=letter -dFIXEDMEDIA -sOutputFile="-" /var/tmp/oct-IYbcMv.ps - | /usr/bin/lpr -l ; rm /var/tmp/oct-IYbcMv.ps'


The diff below will provide more info for debugging.


diff --git a/scripts/plot/print.m b/scripts/plot/print.m
--- a/scripts/plot/print.m
+++ b/scripts/plot/print.m
@@ -292,6 +292,10 @@
     error ("print: no figure to print");
   endif

+  if (opts.debug)
+    opts
+  endif
+
   orig_figure = get (0, "currentfigure");
   set (0, "currentfigure", opts.figure);


Ben Abbott <bpabbott>
Group Member
Wed 30 Jan 2013 11:16:37 PM UTC, comment #4: 

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

@OP:
To invoke fltk: in Octave, type

 graphics_toolkit fltk

and try again.

Philip Nienhuis <philipnienhuis>
Group Member
Wed 30 Jan 2013 07:42:59 PM UTC, comment #3: 

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

Mark van Rossum <cosine>
Wed 30 Jan 2013 04:23:21 PM UTC, 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>
Group administrator
Sat 26 Jan 2013 10:24:47 PM UTC, 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>
Group Member
Fri 25 Jan 2013 11:12:58 AM UTC, 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 Files:
   
   
Comment:
   

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

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 13 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-09-05 bpabbott StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2013-09-05 bpabbott Attached File- Added changeset.patch, #29018
    2013-09-05 bpabbott Attached File- Added changeset.patch, #29015
    2013-09-05 rik5 Attached File- Added eps.crash.patch, #29009
    2013-09-05 bpabbott Attached File- Added changeset.patch, #29008
        Assigned toNone bpabbott
    2013-09-03 bpabbott Release3.6.3 dev
        Operating SystemGNU/Linux Any
    2013-08-31 bpabbott Summarycrash on incorrect print command crash when printing with no output file (i.e. spooling via lpr)
    2013-05-31 mtmiller Dependencies- bugs #39131 is dependent
    2013-01-30 rik5 CategoryInterpreter Plotting with gnuplot
    2013-01-26 philipnienhuis StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code