|
From: Benjamin L. <lin...@gm...> - 2010-03-15 14:24:53
|
Hello list,
I have encountered a nasty problem, namely gnuplot segfaulting if called with a script name and the persistent option and the user then using the terminal window interactively - specifically toggling grid via keyboard 'g'.
Ok, for the details, I see this on windows platform using the windows terminal and only for the 4.5.0 branch, *not* for the 4.4.0 branch.
I am using gnuplot as follows
/path/to/gnuplot/wgnuplot -p foo.gp
where foo.gp simply sets terminal to windows and plots something in 2d like in
set term windows
plot [0:2*pi] sin(x) with linespoints, cos(x) with linespoints
Now pressing "g" crashes gnuplot.
And the nasty part is, it does not always crash (I love those errors...)
But I managed to (hopefully) track it down to :
event_keypress()
builtin_toggle_grid()
do_string_replot()
replotrequest()
m_capture() <- segfault
Here m_capture() is called with both the parameters "start" and "end" as -1 which (not surprisingly) leads to problems as the array token[] is indexed with both start and end.
The problem is, that at the time replotrequest() is called from within do_string_replot(), c_token is -1 and num_token is zero (Why? because do_string_and_free() calls lf_pop(), which sets c_token=-1 and num_token=0).
But apparently replotrequest() assumes that neither is the case, instead it tries to read tokens where there are none.
I don't know where the actual problem lies here. Is it not allowed to call replotrequest() when no tokens are available? Or should replotrequest() make sure that there are tokens available instead of blindly assuming it?
Besides, already replotrequest() accesses token[last_token] (before calling m_capture()) but last_token is -1 if num_tokens is 0 ( as it is the case! ). This makes size_t newlen contain a random number....
I can work around the segfault by the following change
--- a/src/util.c
+++ b/src/util.c
@@ -318,6 +321,9 @@
void
m_capture(char **str, int start, int end)
{
+ if (start<0 || end<0)
+ return;
+
int i, e;
char *s;
but this is (I believe) the wrong place to fix the problem, as replotrequest still accesses token[-1]...
benjamin
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
|
|
From: Ethan M. <merritt@u.washington.edu> - 2010-03-15 19:19:48
|
On Monday 15 March 2010 07:24:39 Benjamin Lindner wrote: > I have encountered a nasty problem, namely gnuplot segfaulting if called with a script name and the persistent option and the user then using the terminal window interactively - specifically toggling grid via keyboard 'g'. > > Ok, for the details, I see this on windows platform using the windows terminal and only for the 4.5.0 branch, *not* for the 4.4.0 branch. > > I am using gnuplot as follows > /path/to/gnuplot/wgnuplot -p foo.gp > > where foo.gp simply sets terminal to windows and plots something in 2d like in > > set term windows > plot [0:2*pi] sin(x) with linespoints, cos(x) with linespoints > > Now pressing "g" crashes gnuplot. > And the nasty part is, it does not always crash (I love those errors...) > [...] > I don't know where the actual problem lies here. Is it not allowed to call replotrequest() > when no tokens are available? I honestly don't know what the windows terminal does when you say "-persist". On other platforms, once the gnuplot program itself exits, you obviously cannot interact with the display to do "replot" or "toggle grid" or anything else that requires reprocessing the input file or command. Ethan |
|
From: Tatsuro M. <tma...@ya...> - 2010-03-16 14:38:08
|
Hello --- Ethan Merritt wrote: > I honestly don't know what the windows terminal does when you say "-persist". > On other platforms, once the gnuplot program itself exits, you obviously cannot > interact with the display to do "replot" or "toggle grid" or anything else that > requires reprocessing the input file or command. > What Benjamin want to do is to be done not by gnuplot -persist foo.gp but by gnuplot foo.gp - By gnuplot foo.gp - gnuplot goes to interactive mode and one can use command key like 'g' on the graph window. However gnuplot 4.5 on windows hangs even if one use gnuplot foo.gp - and press any key or mouse operation on the graph window. I think that it is a problem. As Benjamin stated, on 4.4, the hang up does not happen. Regards Tatsuro -------------------------------------- VANCOUVER 2010 PARALYMPIC GAMES News http://pr.mail.yahoo.co.jp/para/ |
|
From: Jürgen W. <wie...@fr...> - 2010-03-16 15:05:49
|
Am Montag, 15. März 2010 15:24:39 schrieb Benjamin Lindner: > > But I managed to (hopefully) track it down to : > event_keypress() > builtin_toggle_grid() > do_string_replot() > replotrequest() > m_capture() <- segfault > > Here m_capture() is called with both the parameters "start" and "end" as -1 > which (not surprisingly) leads to problems as the array token[] is indexed > with both start and end. > > The problem is, that at the time replotrequest() is called from within > do_string_replot(), c_token is -1 and num_token is zero (Why? because > do_string_and_free() calls lf_pop(), which sets c_token=-1 and > num_token=0). > > But apparently replotrequest() assumes that neither is the case, instead it > tries to read tokens where there are none. A remarkably good bug report. As far as I can see, do_string_replot() should not call a function which takes a look at the command line. I am surprised that this has not produced more problems so far. I assume that part of replotrequest() belongs into replot_command(). Unfortunately, I do not have time to look deeper into this issue. Juergen |
|
From: Tatsuro M. <tma...@ya...> - 2010-03-17 02:07:34
|
Hello I think it is a bug to be reported. In the release note of gnuplot-4.4.0 ************* Support ------- Please report all bugs and installation problems to the bug tracker on SourceForge: http://sourceforge.net/tracker/?group_id=2055&atid=102055 ******************* So please report bug to the sf bug tracker in order to trace the bug easily afterwards. The above note do not deny discussions on the beta ML, I believe. Regards Tatsuro --- J将舐gen Wieferink wrote: > Am Montag, 15. Mセュ璽rz 2010 15:24:39 schrieb Benjamin Lindner: > > > > But I managed to (hopefully) track it down to : > > event_keypress() > > builtin_toggle_grid() > > do_string_replot() > > replotrequest() > > m_capture() <- segfault > > > > Here m_capture() is called with both the parameters "start" and "end" as -1 > > which (not surprisingly) leads to problems as the array token[] is indexed > > with both start and end. > > > > The problem is, that at the time replotrequest() is called from within > > do_string_replot(), c_token is -1 and num_token is zero (Why? because > > do_string_and_free() calls lf_pop(), which sets c_token=-1 and > > num_token=0). > > > > But apparently replotrequest() assumes that neither is the case, instead it > > tries to read tokens where there are none. > > A remarkably good bug report. As far as I can see, > do_string_replot() should not call a function which takes a look at > the command line. I am surprised that this has not produced more > problems so far. I assume that part of replotrequest() belongs into > replot_command(). Unfortunately, I do not have time to look deeper > into this issue. > > Juergen Tatsuro wrote >However gnuplot 4.5 on windows hangs even if one use >gnuplot foo.gp - > and press any key or mouse operation on the graph window. >I think that it is a problem. -------------------------------------- VANCOUVER 2010 PARALYMPIC GAMES News http://pr.mail.yahoo.co.jp/para/ |
|
From: Ethan M. <merritt@u.washington.edu> - 2010-03-17 03:43:23
|
On Tuesday 16 March 2010, Jürgen Wieferink wrote:
> Am Montag, 15. März 2010 15:24:39 schrieb Benjamin Lindner:
> >
> > But I managed to (hopefully) track it down to :
> > event_keypress()
> > builtin_toggle_grid()
> > do_string_replot()
> > replotrequest()
> > m_capture() <- segfault
> >
> > Here m_capture() is called with both the parameters "start" and "end" as -1
> > which (not surprisingly) leads to problems as the array token[] is indexed
> > with both start and end.
> >
> > The problem is, that at the time replotrequest() is called from within
> > do_string_replot(), c_token is -1 and num_token is zero (Why? because
> > do_string_and_free() calls lf_pop(), which sets c_token=-1 and
> > num_token=0).
> >
> > But apparently replotrequest() assumes that neither is the case, instead it
> > tries to read tokens where there are none.
>
> A remarkably good bug report. As far as I can see,
> do_string_replot() should not call a function which takes a look at
> the command line.
I think that part is OK. The idea of the "replot" command is that you can
append a string to it. do_string_replot first executes the old plot command,
then executes the extra string.
> I am surprised that this has not produced more problems so far.
Me too. But it seems to be a simple initialization failure.
When stepping through the arguments on a command line, the program
initializes c_token if the current argument is a file name but not
if the current argument is '-'. The first time we do an lf_push(),
it pushes the initial value of c_token. If that value is garbage,
then trouble ensues.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff -urp gnuplot/src/plot.c gnuplot-cvs/src/plot.c
--- gnuplot/src/plot.c 2010-03-14 11:52:45.000000000 -0700
+++ gnuplot-cvs/src/plot.c 2010-03-16 20:23:31.000000000 -0700
@@ -610,6 +610,7 @@ main(int argc, char **argv)
} else if (strcmp(*argv, "-") == 0) {
/* DBT 10-7-98 go interactive if "-" on command line */
+ c_token = 0;
interactive = TRUE;
/* will this work on all platforms? */
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Tatsuro MATSUOKA <tma...@ya...> wrote >
> I think it is a bug to be reported.
> In the release note of gnuplot-4.4.0
Wait a moment. Benjamin's original bug report said:
> I see this on windows platform using the windows terminal
> and only for the 4.5.0 branch, *not* for the 4.4.0 branch
I was able to replicate this in linux, again only in the 4.5 branch.
Are you also seeing this segfault in 4.4.0?
|
|
From: Tatsuro M. <tma...@ya...> - 2010-03-17 05:11:53
|
Hello --- Ethan Merritt wrote: > Wait a moment. Benjamin's original bug report said: > > I see this on windows platform using the windows terminal > > and only for the 4.5.0 branch, *not* for the 4.4.0 branch > > I was able to replicate this in linux, again only in the 4.5 branch. > > Are you also seeing this segfault in 4.4.0? Perhaps I have misled of the role of the SF buf tracker. The decription of SF buf tracker is the current gnuplot (4.4). The 4.5 branch is development so that it is to be discussed in the beta ML. On 4.4, as you said, we do not see the problem. Sorry for my carelessness. Regards Tatsuro -------------------------------------- VANCOUVER 2010 PARALYMPIC GAMES News http://pr.mail.yahoo.co.jp/para/ |
|
From: Tatsuro M. <tma...@ya...> - 2010-03-17 05:38:01
|
Hello
I have quickly tried the patch for 'gnuplot foo.go -' on windows
--- Ethan Merritt wrote:
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> diff -urp gnuplot/src/plot.c gnuplot-cvs/src/plot.c
> --- gnuplot/src/plot.c 2010-03-14 11:52:45.000000000 -0700
> +++ gnuplot-cvs/src/plot.c 2010-03-16 20:23:31.000000000 -0700
> @@ -610,6 +610,7 @@ main(int argc, char **argv)
>
> } else if (strcmp(*argv, "-") == 0) {
> /* DBT 10-7-98 go interactive if "-" on command line */
> + c_token = 0;
>
> interactive = TRUE;
> /* will this work on all platforms? */
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
----------Tatsuro Wrote
>However gnuplot 4.5 on windows hangs even if one use
>gnuplot foo.gp -
> and press any key or mouse operation on the graph window.
With the patch above, gnuplot foo.gp -
on gnuplot on windows does not give hanging up.
Fine!!
Of course this is different from that Benjamin stated.
At the moment, I cannot enough time to try further.
Regards
Tatsuro
--------------------------------------
VANCOUVER 2010 PARALYMPIC GAMES News
http://pr.mail.yahoo.co.jp/para/
|
|
From: Jürgen W. <wie...@fr...> - 2010-03-17 07:41:50
|
> > A remarkably good bug report. As far as I can see, > > do_string_replot() should not call a function which takes a look at > > the command line. > > I think that part is OK. The idea of the "replot" command is that you can > append a string to it. do_string_replot first executes the old plot > command, then executes the extra string. I know. But that should be done in replot_command() not in replotrequest(). do_string_replot() is called only by other ways like mousing, similar to do_string(), never directly by issuing "replot" from the command line. In those cases, the command line can be in any state and is in no way related to the plot command. > > I am surprised that this has not produced more problems so far. > > Me too. But it seems to be a simple initialization failure. > When stepping through the arguments on a command line, the program > initializes c_token if the current argument is a file name but not > if the current argument is '-'. The first time we do an lf_push(), > it pushes the initial value of c_token. If that value is garbage, > then trouble ensues. Well, after lf_pop() we (hopefully) have exactly the same state as before. And as noone is supposed to have a look at the command line, it is fine to have it uninitialized (btw: should initializing entain num_tokens=0 as well?). Juergen |