#1295 "interactive" session crashes & breaks terminal

closed-fixed
nobody
None
5
2015-03-23
2013-10-17
Markus Appel
No

Hi,
usually I start gnuplot from a terminal (Ubuntu 12.04) by loading a scriptfile and then continue to work in an interactive session:

gnuplot myscript.gp -

No problem here, even though the history is not loaded, which I would prefer, but this discussion belongs maybe elsewhere.

When I start gnuplot (current development version) like this (or with a -e command) and then trigger an error e.g. by typing an invalid command, i get

$ src/gnuplot -e "set xran [0:1]" -
gnuplot> t
^
invalid command

gnuplot immediately closes and leaves me with an unusable terminal, probably due to broken pipes. I bisected this problem back to commit

08cd687 New test for whether a session is interactive or non-interactive

which introduced a new test by looking whether -e or a scriptfile was given in argv and then switched to interactive=false. When I comment out this test in the latest commit everything works fine.

Discussion

  • Ethan Merritt
    Ethan Merritt
    2013-10-23

    I confirm that there is a bug, but your diagnosis is not correct and threw me off for a long time.

    The problem is not the "interactive" flag. That is set correctly to TRUE when input is from "-". The problem is that after an error we LONGJMP through int_error() and restart at a different point in the main loop. At this point it has no idea that previously it was reading from "-" as a command line pseudo file, so it just tries to continue what it was doing before, which was interpreting command line arguments. So if you put multiple "-" in a row it actually would recover in a cock-eyed fashion:
    gnuplot myscript - - - -

    Dumping into true interactive mode instead at that point would be possible, but that would lose the rest of the command line. I.e. you couldn't do
    gnuplot myscript_1 - myscript_2 - myscript_3
    which is possible now though I have no idea if anyone does such a thing.

    Anyhow, I'm scratching my head about how to fix this cleanly.

     
  • Markus Appel
    Markus Appel
    2013-10-23

    Thanks Ethan, and sorry for laying out misleading trails.
    I realized in the meanwhile that there is more to it, as the bug happened again under different circumstances (not sure exactly which ones, but I will keep testing).
    However, the above mentioned changeset seems to have changed the behavior more than probably anticipated:

    08cd687 New test for whether a session is interactive or non-interactive

    $ src/gnuplot -e "print 'header'" - -e "print 'trailer'"
    header
    gnuplot> t
    ^
    invalid command

    gnuplot> t
    ^
    invalid command

    gnuplot> t
    ^
    invalid command
    [session closed, terminal broken]

    as opposed to one changeset earlier

    f2f30da Fix array overrun caused by many 'notitle' plots appearing before any titled plots.

    $ src/gnuplot -e "print 'header'" - -e "print 'trailer'"

    G N U P L O T
    Version 4.7 patchlevel 0 last modified 2012-06-19
    Build System: Linux x86_64

    Copyright (C) 1986-1993, 1998, 2004, 2007-2012
    Thomas Williams, Colin Kelley and many others

    gnuplot home: http://www.gnuplot.info
    mailing list: gnuplot-beta@lists.sourceforge.net
    faq, bugs, etc: type "help FAQ"
    immediate help: type "help" (plot window: hit 'h')

    Terminal type set to 'wxt'
    header
    gnuplot> t
    ^
    invalid command

    header
    gnuplot> t
    ^
    invalid command

    header
    gnuplot> t
    ^
    invalid command

    header
    gnuplot> t
    ^
    invalid command

    header
    gnuplot> q
    trailer
    [session closed]

    Note how earlier the version information was printed and the header was executed every time after an error (don't know if that makes sense though).

    I wasn't aware of this longjmp-business, maybe I will have a look at that.

     
  • Ethan Merritt
    Ethan Merritt
    2013-10-23

    • status: open --> closed-fixed
     
  • Ethan Merritt
    Ethan Merritt
    2013-10-23

    Fixed for both 4.6 and 4.7

    I notice that there is an unrelated further oddity. The "quit" or "exit" command does not work from the interactive part of a session started with "gnuplot script -"