Latest development version.
This is a bit of a corner case. Nonetheless, it might reveal a similar problem with WXT terminal that is crashing when the wxWidgets window is shrunk:
I've noticed that when the x11 window is shrunk small the axes will "invert". That is, instead of the conventional Cartesian plane, it might be the lower, left sector (sector III?) that is shown. In the case where the x-dimension is shrunk, the function lines become completely horizontal. (See first attachment.)
The plot behaves a little more sanely if a similar thing is done in the y-dimension. (See second attachment.)
To show that it is an over/underflow problem, I printed out some numbers with the following change:
Index: term/x11.trm
===================================================================
RCS file: /cvsroot/gnuplot/gnuplot/term/x11.trm,v
retrieving revision 1.226
diff -u -r1.226 x11.trm
--- term/x11.trm 9 Jul 2015 01:40:56 -0000 1.226
+++ term/x11.trm 23 Aug 2016 18:20:40 -0000
@@ -1540,6 +1540,7 @@
if (x == X11_xlast && y == X11_ylast)
return;
PRINT2("V%d %d\n", x, y);
+fprintf(stderr,"V%d %d\n", x, y);
X11_xlast = x;
X11_ylast = y;
}
Here are some sample values:
V1865493790 2443
V1908877292 3119
V1952260794 4142
V1995644296 5472
V2039027799 7054
V2082411301 8824
V2125794803 10710
V3191 2128
V2622 2128
V2622 21217
V3191 21217
Those large values only appear when the shredded lines are visible. So, it isn't gplt_x11.c where the source of the problem, unless it is gplt_x11.c that is feeding an incorrect window size back to gnuplot proper.
In graphics.c is a lot of mapping of the values before the "vector" api function is called. There's probably a signed/unsiged or range-check issue. The mapping is done with a macro used by all axes, so that's not likely the problem since the y-dimension is OK.
I find it hard to care much about this. If you shrink the plot to almost nothing, the contents are uninterpretable. So? Don't do that.
As you note, there is a general problem detecting coordiniate underflow. This is largely because terminal coordinates are defined to be unsigned, but in order to calculate clipping you need the signed (negative) values of lines that run off the edge. In some places the terminal code casts the unsigned coordinate back to signed in order to detect this, but I am not surprised that there are places it doesn't happen. Still, unless this causes a real problem I think it's as you say a corner case that can be tolerated.
I agree that the wxt terminal should not crash when shrunk. But I can't reproduce the problem so other than suggesting that a minimum size be enforced I can't offer much help. Can you trap enough of a call chain to say where and why it crashed. Is it because a requested window size goes negative (or wraps around to huge unsigned positive)?
Not much time right now, but quickly. I printed out some info to determine it is this code hunk that is primarily executed, i.e., plot_lines():
The x,y --> xmap,ymap (i.e., float to integer) is where the wild numbers for x are coming from.
I then did the following:
to see exactly what is wrong in the formula and I'm consistently see
It's that x min value in the struct axis that seems out of bound, whereas the y min value doesn't seem to do that.
All I have time for right now...
I still don't see why this is a problem worth fixing.
If you shrink the plot window down to nothing, then the plot won't fit. So?
I'm trying to understand this one in hopes that it leads to the WXT crash bug. (Looks like they aren't the same.) Crash bugs are definitely a concern. Not shrinking the window size is fine if one knows to not do that, but even then it is typically an inadvertent action that causes such a thing. For example, depending on the mouse pad, sometimes optical mice will peg to one end of the screen or another. If that happens when resizing a window, the window shrinks. Plus, who knows how else it might be possible to create this situation, say the user manually sets the plot size fairly small and then resizes the window?
Anyway, I know what is happening here now. I noticed that this error message was only appearing when shrinking the x axis so that it inverts, but not for y-axis:
I watched ytop and ybot, and the strangely inverted roles when I expected ytop < ybot. The reason is that preceding this hunk of code is
So, there's a hunk of code to flip ytop/ybot if necessary to ensure proper order. But there is no such code for xright/xleft. That's why this is occuring. Perhaps the ybot/ytop should not be interchanged, but instead allow it too to cause a warning. Also, as the comment says, maybe a stricture test is in order...not a fatal test, but simply do not draw the plot. If there is no plot and a warning message, the user will figure out what the problem is.
I don't think this is related to the WXT bug.