Subject: | plshades() crashes on 64-bit PowerPC |
I experience a crash when running tests on 64-bit PowerPC (big or little endian):
t/plplot.t ................
All 15 subtests passed
sh: line 1: 28335 Segmentation fault (core dumped) perl -Mblib ./t/x09.pl -dev svg -o x09p.svg -fam > /dev/null 2>&1
# Failed test 'Script ./t/x09.pl ran successfully'
# at t/plplot_library_tests.t line 68.
# Failed test 'Output file x09p.svg.2 matches C output'
# at t/plplot_library_tests.t line 74.
sh: line 1: 28730 Segmentation fault (core dumped) perl -Mblib ./t/x22.pl -dev svg -o x22p.svg -fam > /dev/null 2>&1
# Failed test 'Script ./t/x22.pl ran successfully'
# at t/plplot_library_tests.t line 68.
# Failed test 'Output file x22p.svg.1 matches C output'
# at t/plplot_library_tests.t line 74.
# Looks like you failed 4 tests of 221.
t/plplot_library_tests.t ..
Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/221 subtests
Test Summary Report
-------------------
t/plplot.t (Wstat: 139 Tests: 15 Failed: 0)
Non-zero wait status: 139
Parse errors: No plan found in TAP output
t/plplot_library_tests.t (Wstat: 1024 Tests: 221 Failed: 4)
Failed tests: 67, 69, 122-123
Non-zero exit status: 4
Files=2, Tests=236, 41 wallclock secs ( 0.05 usr 0.01 sys + 13.73 cusr 1.06 csys = 14.85 CPU)
Result: FAIL
The crash is caused by dereferencing inaccessible grid pointer in pltr1() function, plplot-5.11.1/src/plcont.c:896:
void
pltr1( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer pltr_data )
{
PLINT ul, ur, vl, vr;
PLFLT du, dv;
PLFLT xl, xr, yl, yr;
PLcGrid *grid = (PLcGrid *) pltr_data;
PLFLT *xg = grid->xg;
PLFLT *yg = grid->yg;
PLINT nx = grid->nx;
→ PLINT ny = grid->ny;
Minimal reproducer is to run this code:
use PDL;
use PDL::Config;
use PDL::Graphics::PLplot;
my $dev = 'xfig';
# Test shade plotting (low level interface)
plsdev ($dev);
plsfnam ("test12.$dev");
plspage (0,0, 600,600, 0,0);
plinit();
pladv (0);
plvpor(0.1, 0.9, 0.1, 0.9);
plwind (-1, 1, -1, 1);
plpsty(0);
my $nx = 35;
my $ny = 46;
my $x = (sequence($nx) - ($nx/2))/($nx/2);
my $y = (sequence($ny) - ($ny/2))/(($ny/2) - 1.0);
my $xv = $x->dummy(1, $y->nelem);
my $yv = $y->dummy(0, $x->nelem);
my $z = -sin(7*$xv) * cos (7*$yv) + $xv**2 - $yv**2;
my $nsteps = 15;
my ($zmin, $zmax) = $z->minmax;
my $clevel = ((sequence($nsteps)*(($zmax - $zmin)/($nsteps-1))) + $zmin);
my $xmap = ((sequence($nx)*(2/($nx-1))) + -1); # map X coords linearly to -1 to 1
my $ymap = ((sequence($ny)*(2/($ny-1))) + -1);
my $grid = plAllocGrid ($xmap, $ymap);
plshades($z, -1, 1, -1, 1,
$clevel, 2,
0, 0, 1,
0, \&pltr1, $grid);
I have no idea where the problem is, maybe it's a bug in plplot. See <https://bugzilla.redhat.com/show_bug.cgi?id=1410774> for more details.