Contourf + quiet mode = segfault; additionally, areas filled improperly #318
Labels
bug - runtime error
cross-platform issue - linux
Help wanted - Good for contributing if you are on linux
Bug category
Describe the bug
In the code below, five examples (replace
input0();
withinput1();
...input4();
inmain()
to load the data for the other examples) demonstrate issues I had with the filed contour plotscontourf
. I presume that those issues might be related (or maybe they are not). Apart from that, I'd like to thank you for this excellent library - I was stunned when I stumbled upon the project :) Not having to export examples to a Matlab code to merely check them out there is tremendous help.Example 0 (
input0
):figure(true);
.matplot::contours::is_lower_level
figure(false);
), segfault is not produced; however, the calculated levels, as indicated by the colorbar, are garbage. See the produced plot below.contourf
version on the same data.X
,Y
in this example are not produced bymeshgrid
(rather, they correspond tomeshgrid
). I could not produce an example where the segfault happened with data of the fromauto [X, Y] = meshgrid(x, y);
Images for example 0
Example 1 (
input1
):meshgrid
;Images for example 1
Example 2 (
input2
):meshgrid
;matplot++
, the second by Matlab on the same data.Images for example 2
Example 3 (
input3
):meshgrid
, but of the formX
,Y
,Z
correspond to values ofmatplot++
produces an example with a sector 'cut out', see the first image below. Matlab on the same data produces a correct contour plot.Images for example 3
Example 4 (
input4
):X.push_back(X[1]);
for all arrays in Example 3).matplot++
produces a correct plot (see below); also so does Matlab on the same data (and the resulting plot is identical toimg3M
above).Image for example 4
Additional notes
figure(false);
andfigure(true);
reproduce the same behavior, i.e., the improper filling does not depend upon the mode for figure.//contourf(X,Y,Z);
but comments out the three lines above, the behavior is the same in all examples.contourf
and even thematplot::contours::is_lower_level
member (e.g., the open issue axes_objects/contourc.cpp:584: out-of-bounds while accessing the _Z_rows[n_col][n_row] in contours::is_lower_level() #77 - but not sure if it is related)matplot++
library was built withCMAKE_BUILD_TYPE=Debug
(but the bug was present also on the Release version):cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF cmake --build . --parallel 2 --config Debug
contour(X,Y,Z)
in all examples and settings worked perfectly.Steps to Reproduce
Source code and data:
Building:
g++ -g -o out prog.cpp -lmatplot && ./out
Output
Segmentation fault (core dumped)
GNU gdb (Ubuntu 12.1-3ubuntu2) 12.1 output
valgrind output (if that's of any help):
Output: https://pastebin.com/TeQxuWv0
Platform
Environment Details:
The text was updated successfully, but these errors were encountered: