#1055228 plplot: FTBFS on armhf (test segfault)

Package:
src:plplot
Source:
src:plplot
Submitter:
Gianfranco Costamagna
Date:
2024-01-20 13:57:03 UTC
Severity:
normal
Tags:
#1055228#5
Date:
2023-11-02 14:09:10 UTC
From:
To:
Hello, I found the package FTBFS on Ubuntu, checked on amdahl and found the same issue.

/usr/bin/make  -f examples/fortran/CMakeFiles/x31f.dir/build.make examples/fortran/CMakeFiles/x31f.dir/build
make[5]: Entering directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
make[5]: Nothing to be done for 'examples/fortran/CMakeFiles/x31f.dir/build'.
make[5]: Leaving directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
[ 46%] Built target x31f
/usr/bin/make  -f examples/CMakeFiles/test_fortran_svg.dir/build.make examples/CMakeFiles/test_fortran_svg.dir/depend
make[5]: Entering directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
cd /home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/locutusofborg/plplot-5.15.0+dfsg2 /home/locutusofborg/plplot-5.15.0+dfsg2/examples /home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf /home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf/examples /home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf/examples/CMakeFiles/test_fortran_svg.dir/DependInfo.cmake "--color="
make[5]: Leaving directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
/usr/bin/make  -f examples/CMakeFiles/test_fortran_svg.dir/build.make examples/CMakeFiles/test_fortran_svg.dir/build
make[5]: Entering directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
cd /home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf/examples && /usr/bin/cmake -E echo "Generate fortran results for svg device"
Generate fortran results for svg device
cd /home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf/examples && env EXAMPLES_PREFIX=/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf/examples SRC_EXAMPLES_PREFIX=/home/locutusofborg/plplot-5.15.0+dfsg2/examples OUTPUT_DIR=/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf/examples/test_examples_output_dir /bin/bash /home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf/plplot_test/plplot-test.sh --verbose --front-end=fortran --device=svg
Testing front-end fortran
x16af
x00f
x01f
x02f
x03f
x04f
x05f
x06f
x07f
x08f
x09f
/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf/plplot_test/test_fortran.sh: line 54: 3932208 Bus error               $DEBUG_CMD "$fortrandir"/x${index}f -dev $device -o "${OUTPUT_DIR}"/x${index}${lang}%n.$dsuffix $options 2> fortran_${device}_test.error >| "${OUTPUT_DIR}"/x${index}${lang}_${dsuffix}.txt

Program received signal SIGBUS: Access to an undefined portion of a memory object.

Backtrace for this error:
make[5]: *** [examples/CMakeFiles/test_fortran_svg.dir/build.make:388: examples/test_examples_output_dir/x00f01.svg] Error 1
make[5]: *** Deleting file 'examples/test_examples_output_dir/x00f01.svg'
make[5]: Leaving directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
make[4]: *** [CMakeFiles/Makefile2:5049: examples/CMakeFiles/test_fortran_svg.dir/all] Error 2
make[4]: Leaving directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
make[3]: *** [CMakeFiles/Makefile2:7121: examples/CMakeFiles/test_noninteractive.dir/rule] Error 2
make[3]: Leaving directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
make[2]: *** [Makefile:2243: test_noninteractive] Error 2
make[2]: Leaving directory '/home/locutusofborg/plplot-5.15.0+dfsg2/obj-arm-linux-gnueabihf'
make[1]: *** [debian/rules:55: override_dh_auto_test] Error 2
make[1]: Leaving directory '/home/locutusofborg/plplot-5.15.0+dfsg2'
make: *** [debian/rules:48: binary] Error 2


Full log attached


G.

#1055228#12
Date:
2023-11-09 16:11:21 UTC
From:
To:
* Gianfranco Costamagna <locutusofborg@debian.org> [2023-11-02 15:09]:

Thanks for this bug report. I can indeed reproduce the problem.

It was triggered by the recent change in dpkg-buildflags, which now
includes -fstack-clash-protection in FFLAGS. This was done through commit
1d46b351f [1], , intended to fix Bug#1054583 [2], and which got included
in version 1.22.1 of dpkg-dev, released on October 30.

The Fortran example x09f.f90, which is exercised during the building of
plplot, now fails on armhf, due to the use of the compiler option
-fstack-clash-protection. I did not check whether this is also the case 
for arm64 and armel.

As far as I can tell, this is due to a global variable (tr) that is not
correctly accessed in a private function (mypltr) of the x09f program.

There may be a programming error in x09f.f90 or this may be a problem
with gfortran on armhf. My knowledge of Fortran is almost non existent
and I will need the help of experts, in order to fix the issue.

Best,

Rafael Laboissière

  [1] https://git.dpkg.org/cgit/dpkg/dpkg.git/diff/?id=1d46b351f
  [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1054583

#1055228#19
Date:
2023-11-10 19:45:31 UTC
From:
To:
* Rafael Laboissière <rafael@debian.org> [2023-11-09 17:11]:
https://bugs.debian.org/1055750

Best,

Rafael Laboissière

#1055228#24
Date:
2023-11-15 17:20:25 UTC
From:
To:
Hi!

The problem seems unrelated to stach-clash-protection I think, enabling
the feature on armhf just made it evident.

Building the program on a x86 system without -fstack-clash-protection
but with -fsanitize=address, it segfaults:

 /usr/bin/gfortran -g -O2 x09f.f90 -o x09f -I/usr/lib/x86_64-linux-gnu/fortran/modules/plplot -lplplotfortran -fsanitize=address
 ./x09f -dev ps -o /dev/null

 Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

The SIGSEGV happens in plplot_single::pltransformf2c, which is about
where the SIGBUS happens on armhf with stack-clash-protector enabled:

 Program received signal SIGSEGV, Segmentation fault.
 0x00007ffff5a000a8 in ?? ()
 (gdb) bt
 #0  0x00007ffff5a000a8 in ?? ()
 #1  0x00007ffff7f05683 in plplot_single::pltransformf2c (x=x@entry=0, y=y@entry=1, tx=4.9406564584124654e-324,
     ty=6.9533558054215925e-310, data=<error reading variable: Attempt to dereference a generic pointer.>)
     at ./bindings/fortran/plplot_single.f90:114

Here's the SIGBUS on armhf with stack-clash-protection:

 Program received signal SIGBUS, Bus error.
 0x00400822 in x09f::mypltr (x=0, y=1, xt=0, yt=0) at x09f.f90:38
 38              xt = tr(1) * x + tr(2) * y + tr(3)
 (gdb) bt
 #0  0x00400822 in x09f::mypltr (x=0, y=1, xt=0, yt=0) at x09f.f90:38
 #1  0xf7f58a06 in plplot_single::pltransformf2c (x=<optimized out>, y=<optimized out>, tx=-9.8841854819221187e+269,
     ty=-nan(0xe5db400000001), data=<optimized out>) at ./bindings/fortran/plplot_single.f90:114

#1055228#29
Date:
2023-11-21 16:13:20 UTC
From:
To:
* Emanuele Rocca <ema@debian.org> [2023-11-16 09:30]:

Thanks for the suggestion, Emanuele.

I am hereby merging both bugs, which are now both assigned to plplot.

Best,

Rafael Laboissière

#1055228#42
Date:
2023-11-21 16:29:22 UTC
From:
To:
severity 1055750 serious
merge 1055750 1055228

#1055228#57
Date:
2024-01-01 19:13:45 UTC
From:
To:
plplot got removed from armhf, the severity of this issue could be
lowered to important to not have the package removed from testing.

Kind Regards,

Bas

#1055228#62
Date:
2024-01-01 21:16:13 UTC
From:
To:
* Sebastiaan Couwenberg <sebastic@xs4all.nl> [2024-01-01 20:13]:

Thanks, I am doing it hereby.

Best,

Rafael Laboissière

#1055228#69
Date:
2024-01-17 15:22:29 UTC
From:
To:
Hi Rafael,

as a workaround for this issue, you could disable stack-clash-protection
when building for armhf. The following snippet in debian/rules should do
the trick:

  ifeq ($(DEB_TARGET_ARCH),armhf)
    DEB_BUILD_MAINT_OPTIONS = hardening=+all,-stackclash
  else
    DEB_BUILD_MAINT_OPTIONS = hardening=+all
  endif

Thanks,
  Emanuele

#1055228#74
Date:
2024-01-20 13:55:34 UTC
From:
To:
* Emanuele Rocca <ema@debian.org> [2024-01-17 16:22]:

Thanks for this suggestion, Emanuele.

I added your changes to version 5.15.0+dfsg2-7+deb13u1 of the package,
uploaded to unstable, and it worked:

https://buildd.debian.org/status/fetch.php?pkg=plplot&arch=armhf&ver=5.15.0%2Bdfsg2-7%2Bdeb13u1&stamp=1705741947&raw=0

Best,

Rafael