lapack icon indicating copy to clipboard operation
lapack copied to clipboard

[v3.12.0] sblat1.f (SNRM2) test fail on i386 architectures

Open cdluminate opened this issue 1 year ago • 7 comments

Description

The sblat1.f test fails on i386 architectures, including i386 (effectively i686), and hurd-i386: https://buildd.debian.org/status/package.php?p=lapack&suite=experimental https://buildd.debian.org/status/fetch.php?pkg=lapack&arch=i386&ver=3.12.0-1&stamp=1702247469&raw=0 https://buildd.debian.org/status/fetch.php?pkg=lapack&arch=hurd-i386&ver=3.12.0-1&stamp=1702271309&raw=0

The typical failure is the SNRM2 call, which look like:

 Test of subprogram number  7            SNRM2 
                                       FAIL
  SNRM2: N=     4, INCX=  -2, IV= 9, IW= 9, test= 0.20971520E+07
                                       FAIL
  SNRM2: N=     4, INCX=   1, IV= 9, IW= 9, test= 0.20971520E+07
                                    ----- PASS -----

I'm confused about why this failure does not occur on other 32-bit architectures such as armhf and m68k. Any idea? It does not seem like a compiler issue neither. Both gfortran-12 and gfortran-13 lead to the same results.

The minimal example to reproduce this issue is to build this package on a clean Debian unstable (sid) chroot.

Checklist

  • [x] I've included a minimal example to reproduce the issue
  • [x] I'd be willing to make a PR to solve this issue

cdluminate avatar Dec 20 '23 00:12 cdluminate

There is a typo in the test that on most systems apparently yields a zero, but not on the two systems above.

@cdluminate I sent you an email.

angsch avatar Dec 20 '23 06:12 angsch

BTW, the following is the default build flags for Debian (distribution-wide):

CFLAGS=-g -O2 -ffile-prefix-map=/home/lumin=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection
CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2
FFLAGS=-g -O2 -ffile-prefix-map=/home/lumin=. -fstack-protector-strong -fstack-clash-protection -fcf-protection
LDFLAGS=-Wl,-z,relro

I've not yet verified which argument triggered the bug. But I cannot reproduce the issue on i386 with the default flags in make.inc. The bug only appears when built using debian's flags and tools. There is a resemblance to https://github.com/Reference-LAPACK/lapack/pull/961 which is only triggered by coverage build.

cdluminate avatar Dec 21 '23 02:12 cdluminate

Ok, after fixing the test implementation (https://github.com/Reference-LAPACK/lapack/pull/964), the ZDNRM2 test breaks again with Debian specific build flags. I think I should try to contribute a CI test with Debian build flags. Those stack protection flags can help you guys catch more bugs.

cdluminate avatar Dec 21 '23 03:12 cdluminate

With the default flags in make.inc. The test passed. But with stack protections, you can reproduce the issue with (1) the following config, (2) Patch #964, and (3) the command make blas_testing on an amd64 machine.

21c21
< FFLAGS = -O2 -frecursive
---
> FFLAGS = -g -O2 -fstack-protector-strong -fstack-clash-protection -fcf-protection
27c27
< LDFLAGS =
---
> LDFLAGS = -Wl,-z,relro

The error looks like

 Test of subprogram number  6            DZNRM2                                                                                
                                       FAIL                                                                                    
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 1, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 2, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 3, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 4, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 5, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 6, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 7, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 8, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW= 9, test=            NaN                                                               
 DZNRM2: N=     1, INCX=  -2, IV= 9, IW=10, test=            NaN                                                               
                                       FAIL                                                                                    
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 1, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 2, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 3, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 4, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 5, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 6, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 7, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 8, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW= 9, test=            NaN                                                               
 DZNRM2: N=     1, INCX=   1, IV= 9, IW=10, test=            NaN                                                               
                                       FAIL                                                                                    
 DZNRM2: N=     2, INCX=  -2, IV= 1, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 2, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 3, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 4, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 5, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 6, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 7, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 8, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 1, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 2, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 3, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 4, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 5, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 6, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 7, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 8, test=            NaN                                                               
 DZNRM2: N=     2, INCX=  -2, IV= 9, IW= 9, test=            NaN                                                               
                                       FAIL                                                                                    
 DZNRM2: N=     2, INCX=   1, IV= 1, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=   1, IV= 2, IW= 9, test=            NaN                                                               
 DZNRM2: N=     2, INCX=   1, IV= 3, IW= 9, test=            NaN          

[...truncated...]

Update: cblas1.f fails just like zcblas1.f.

cdluminate avatar Dec 21 '23 03:12 cdluminate

I will have a look at this on the weekend.

angsch avatar Dec 21 '23 16:12 angsch

@cdluminate Do you confirm that this issue is indeed fixed by #964? My understanding was that this PR was not enough.

svillemot avatar Jun 21 '24 08:06 svillemot