|
From: Ethan A M. <me...@uw...> - 2023-03-08 17:56:10
|
On Tuesday, 7 March 2023 11:38:22 PST Juhász Péter wrote:
> The following data file + gnuplot script produce incorrect behavior
> with a recent git build, indicating possible memory corruption while
> reading strings from the data file:
>
> # -- data file ---
> 1;1;
> 1;2;
> 1aa;3;1.1
> 1;4;
> 1;5;
> 1;2;
> 1;3;
> 1;4;
> 1;5;
>
> # -- script ----
> set dataf sep ';'
> plot 'foo' u 0:2:(strcol(3)) w labels point
>
>
> On my machine this produces a plot where all points after the third
> have the same "1.1" label. When you move the plot around (in an
> interactive terminal, e.g. with an arrow key), all points get the same
> label.
Yes, a bug. Or arguably two bugs.
An empty final field in a csv file was correctly flagged as "missing",
but the string-handling code did not check for this flag. Instead it
used a leftover pointer from a previous string operation.
Two fixes now applied to 5.4 6.0 6.1
1) Clear pointer to previous string operation when an empty
field is encountered
2) In the string-handling code (df_parse_string_field) substitute
a new empty string for a NULL string pointer
Ethan
> Interestingly, everything seems to work as expected if you remove the
> "a"s from the data file. Other, even weirder effects can be coaxed out
> of gnuplot if you add some characters to other lines than the third.
>
> This seems like a bug. I think the explicit non-standard separator and
> the field being the last one are both necessary conditions.
>
> Some background and explanation:
>
> This report is actually related to an earlier discussion on this list,
> where I complained that lines containing missing values are silently
> dropped, and that column(i) seemed different from $i. Today I updated
> to the current development version, and noticed that my workaround to
> the missing values using column() no longer worked. So I experimented
> with some things, and at first I've thought that strcol() might be able
> to help me, as it didn't seem to be bothered by missing fields, but
> then I noticed the weirdness described above.
>
> As for fixing this bug, I think it is important to preserve strcol()'s
> ability to just return the empty string in case of missing data - after
> all, it is advertised to return the content of column X as a string. If
> the column is empty, then by definition its contents are the empty
> string.
>
> best regards,
> Peter Juhasz
|