lapack icon indicating copy to clipboard operation
lapack copied to clipboard

hppa: Segmentation fault in c_sblat3 test

Open danglin44 opened this issue 4 months ago • 3 comments

See: [(https://buildd.debian.org/status/fetch.php?pkg=lapack&arch=hppa&ver=3.12.1-4&stamp=1753202248&raw=0)]

dave@mx3210:~/debian/lapack/lapack-3.12.1/CBLAS/testing$ gdb -c core.25930 ./xscblat3 GNU gdb (Debian 16.3-1) 16.3 Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "hppa-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./xscblat3... [New LWP 25930] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/hppa-linux-gnu/libthread_db.so.1". Core was generated by `./xscblat3'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00013d1c in smake (type=..., uplo=..., diag=..., m=, n=, a=..., nmax=, aa=..., --Type <RET> for more, q to quit, c to continue without paging-- lda=, reset=, transl=, _type=, _uplo=, _diag=) at c_sblat3.f:2182 2182 AA( I + ( J - 1 )*LDA ) = ROGUE (gdb) bt #0 0x00013d1c in smake (type=..., uplo=..., diag=..., m=, n=, a=..., nmax=, aa=..., lda=, reset=, transl=, _type=, _uplo=, _diag=) at c_sblat3.f:2182 #1 0x00014394 in schk6 (sname=..., eps=, thresh=, nout=<error reading variable: Cannot access memory at address 0xbdbe4613>, ntra=, trace=, rewi=, fatal=, nidim=, idim=..., nalf=, alf=..., nbet=, bet=..., nmax=, a=..., aa=..., as=..., b=..., bb=..., bs=..., c=..., cc=..., cs=..., ct=..., g=..., iorder=, _sname=) at c_sblat3.f:2624 #2 0x0001e7b8 in sblat3 () at c_sblat3.f:369

This fault occurs in the SCHK6 test. The array IDIM is clobbered by the memcpy call used to implement this loop in the SCHK6 test:

                       DO 30 I = 1, LCC
                          CS( I ) = CC( I )

30 CONTINUE LDCS = LDC

I believe this is caused by a mismatch between the callee arguments for SCHK6

185 IF (CORDER) THEN CALL SCHK6( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, $ NMAX, AB, AA, AS, BB, BS, C, CC, CS, CT, G, W, $ 0 )

        END IF
        IF (RORDER) THEN
        CALL SCHK6( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE,
 $                  REWI, FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET,
 $                  NMAX, AB, AA, AS, BB, BS, C, CC, CS, CT, G, W,
 $          1 )
        END IF

and the implementation

  SUBROUTINE SCHK6( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI,
 $                  FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, NMAX,
 $                  A, AA, AS, B, BB, BS, C, CC, CS, CT, G,
 $                  IORDER)

Argument "B" is dropped and argument "W" is added to keep the number of REAL arguments the same. I'm not sure why this inconsistency is not detected by gcc. Maybe "-Wall" is needed.

If SCHK6 test is skipped, lapack builds successfully on hppa.

Checklist

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

danglin44 avatar Aug 12 '25 14:08 danglin44

It appears alpha is affected by the same bug.

danglin44 avatar Aug 12 '25 15:08 danglin44

Hi @danglin44, can you send the lines of codes using "permalink" features of GitHub. Something like https://github.com/Reference-LAPACK/lapack/blob/bfbef596de9c445075b809f127e85c379884e209/BLAS/TESTING/sblat3.f#L344-L347 I cannot identify the lines of codes you are pointing you. Cheers, @langou

langou avatar Aug 12 '25 16:08 langou

Found it! https://github.com/Reference-LAPACK/lapack/blob/bfbef596de9c445075b809f127e85c379884e209/CBLAS/testing/c_sblat3.f#L365-L369 This was in CBLAS not BLAS, my bad.

langou avatar Aug 12 '25 16:08 langou