|
From: Daniel J S. <dan...@ie...> - 2006-05-29 01:38:06
|
I wrote up a bug report on a bad pointer which manifests itself as stuff like this:
Terminal type set to 'x11'
gnuplot> f(x) = x+a
gnuplot> g(x) = x+b
gnuplot> plot f(x)
undefined variable: a
gnuplot> reset
gnuplot> plot f(x)
undefined variable: 4
The 4 is just some random gibberish and will sometimes crash.
I'd rather someone else fix this one because the solution will be quite involved, but I've described in detail in the bug report exactly where/why it is crashing.
Dan
|
|
From:
<br...@ph...> - 2006-05-29 11:06:32
|
Daniel J Sebald wrote: > gnuplot> f(x) = x+a > gnuplot> g(x) = x+b > gnuplot> plot f(x) > undefined variable: a > gnuplot> reset > gnuplot> plot f(x) > undefined variable: 4 The problem is in 'reset': that command is not supposed to as much as *look* at the user-defined variables in the first place, much less remove any of them, whether they're in limbo or not. |
|
From: Ethan A M. <merritt@u.washington.edu> - 2006-05-29 15:27:56
|
On Monday 29 May 2006 04:06 am, Hans-Bernhard Br=F6ker wrote: >=20 > The problem is in 'reset': that command is not supposed to as much as=20 > *look* at the user-defined variables in the first place, much less=20 > remove any of them, whether they're in limbo or not. It only removes undefined variables. This is only garbage-collection mechanism we have for such space, so if you remove it we will end up with the opposite problem of a memory leak. The issue is that the parsing code uses add_udv(), which results in=20 space allocation for every variable mentioned, whether or not it is a correctly defined variable. For example: print nonsense allocates space for a variable "nonsense" before reporting that it is undefined. This space will only be released if you later define "nonsense" properly, or do a reset.=20 > gnuplot> f(x) =3D x+a > gnuplot> g(x) =3D x+b > gnuplot> plot f(x) > undefined variable: a I am inclined to say that the definition of f(x) should fail if there=20 is no previously-defined variable 'a'. Alternatively, the code that creates an evaluation stack for 'f(x)' could initialize a to 0 rather than leaving it undefined. =2D-=20 Ethan A Merritt Biomolecular Structure Center University of Washington, Seattle 98195-7742 |
|
From: Daniel J S. <dan...@ie...> - 2006-05-29 17:41:06
|
Ethan A Merritt wrote: > On Monday 29 May 2006 04:06 am, Hans-Bernhard Br=F6ker wrote: >=20 >>The problem is in 'reset': that command is not supposed to as much as=20 >>*look* at the user-defined variables in the first place, much less=20 >>remove any of them, whether they're in limbo or not. >=20 >=20 > It only removes undefined variables. This is only garbage-collection > mechanism we have for such space, so if you remove it we will end > up with the opposite problem of a memory leak. >=20 > The issue is that the parsing code uses add_udv(), which results in=20 > space allocation for every variable mentioned, whether or not it is > a correctly defined variable. For example: > print nonsense > allocates space for a variable "nonsense" before reporting that it > is undefined. This space will only be released if you later define > "nonsense" properly, or do a reset.=20 >=20 >=20 >>gnuplot> f(x) =3D x+a >>gnuplot> g(x) =3D x+b >>gnuplot> plot f(x) >> undefined variable: a >=20 > I am inclined to say that the definition of f(x) should fail if there=20 > is no previously-defined variable 'a'. Well, that is an alternative. It's the same thing as I was just looking = at for checking that the number of input variables to a function match. = (A very useful feature, BTW.) At first my thinking was that gnuplot shou= ld complain if it tries to use a function that hasn't been defined and do= esn't have the correct number of input variables. But then I saw that gnuplot seems to be set up to not check/verify anythi= ng until interpretation. I personally wouldn't get into a programming ha= bit of using variables I haven't defined, but I can live with that philos= ophy. If that is the concept, then neither functions (as is currently the case)= nor variables can be removed even if they are undefined, unless intentio= nally removed. Whatever the case, both functions and variables should behave the same wa= y. As for cleaning up the variable space, an eventual 'reset' or 'unset' to = do that would be good. I would say that having the function argument keep track of the memory po= inter as well as the linked list of variables is marginal programming pra= ctice. Pointers in lists are something that should only be used temporar= ily on the fly, and not stored in multiple places. I see the issue, howe= ver, which is speed. Can the pointers be looked up at the time of the pl= ot command, used in the command, and then discarded? [Keep in mind I don= 't understand the code too well, that's why I punted.] > Alternatively, the code that creates an evaluation stack for 'f(x)' > could initialize a to 0 rather than leaving it undefined. That I don't think is acceptable. If I define a function involving some = variable I've not defined and gnuplot assumes it equals zero, that wouldn= 't be good. I could never know the difference in some instances of compl= icated functions I'm not familiar with. Dan |