Test routines ZDRVHEX, ZDRVSYX can seg fault

Post here if you want to report a bug to the LAPACK team

Test routines ZDRVHEX, ZDRVSYX can seg fault

Postby mickpont » Wed Nov 30, 2011 8:15 am

When running zchkaa.exe < ztest.in, the test program can seg fault
or cause memory overwrites because a pointer to INTEGER instead of
REAL or DOUBLE PRECISION workspace is passed to other routines.
The affected test routines are in the TESTING/LIN directory, and are:

zdrvhex.f (line 613)
cdrvhex.f (line 613)
zdrvsyx.f (line 619)
cdrvsyx.f (line 619)

Using zdrvhex.f as an example, line 613 looks like this:

CALL ZHESVXX( FACT, UPLO, N, NRHS, A, LDA, AFAC,
$ LDA, IWORK, EQUED, WORK( N+1 ), B, LDA, X,
$ LDA, RCOND, RPVGRW_SVXX, BERR, N_ERR_BNDS,
$ ERRBNDS_N, ERRBNDS_C, 0, ZERO, WORK,
$ IWORK( N+1 ), INFO )

The penultimate argument to ZHESVXX should be DOUBLE PRECISION,
but INTEGER array IWORK( N+1 ) is passed instead. Replacing IWORK( N+1 )
by RWORK seems to fix the problem.

Note that the corresponding REAL and DOUBLE PRECISION versions of the four
affected routines are OK - they do need to pass INTEGER workspace for this argument.

Mick Pont
NAG, Oxford
mickpont
 
Posts: 6
Joined: Wed Jul 18, 2007 4:31 am
Location: Oxford, UK

Re: Test routines ZDRVHEX, ZDRVSYX can seg fault

Postby Julien Langou » Wed Nov 30, 2011 9:39 am

Hi Mick, I have just applied your patch to the four routines. Available in the svn repository. Thanks a lot! Regarding your second post of the day, I will have a look later in the morning. Cheers, Julien.
Last edited by Julien Langou on Wed Nov 30, 2011 12:19 pm, edited 1 time in total.
Julien Langou
 
Posts: 734
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Re: Test routines ZDRVHEX, ZDRVSYX can seg fault

Postby Julien Langou » Wed Nov 30, 2011 11:18 am

FYI, I was doing a code review of zdrvhex, the previous code (previous = before Mick's patch) was passing as the RWORK array for zhesvxx (penultimate argument) the array IWORK(N+1). Two problems: first IWORK is an INTEGER array passed for a REAL array, (Mick's point, we areally need (void *) in FORTRAN!). Another issue is that IWORK is of dimension (NMAX), see the header of zdrvhex, so that moving in position N+1 is not really a good idea. So now replacing IWORK(N+1) by RWORK kind of help. My issue now is that zhesvxx expect RWORK to be of dimension (2*N) -- see header of zhesvxx -- while RWORK is of dimension (NMAX+2*NRHS) in zdrvhex -- see the header of zdrvhex. So I guess there is another fix needed. Cheers, Julien.
Last edited by Julien Langou on Wed Nov 30, 2011 12:19 pm, edited 1 time in total.
Julien Langou
 
Posts: 734
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Re: Test routines ZDRVHEX, ZDRVSYX can seg fault

Postby mickpont » Wed Nov 30, 2011 11:51 am

Hi Julien,

> first IWORK is
> an INTEGER array passed for a REAL array, (Mike's point, we areally need
> (void *) in FORTRAN!)

the problem wasn't so much due to lack of void * in Fortran, as the fact that
the integer array was not nicely aligned in memory. If it had been, and it had been
big enough, then the problem would have gone unnoticed. As it was, the compiler
generated code assuming the the array was aligned nicely and used SSE instructions
to access it. That's what caused the crash - x64 assembly instructions like movapd
cannot be used on unaligned memory.

> My issue now
> is that zhesvxx expect RWORK to be of dimension (2*N) -- see header of
> zhesvxx -- while RWORK is of dimension (NMAX+2*NRHS) in zdrvhex -- see the
> header of zdrvhex. So I guess there is another fix needed.

I think all that's needed is to change the comment in the header of zdrvhex.
The main program zchkaa does make the RWORK array big enough for
the requirement here, and passes it to zdrvhe, so it actually has enough
memory. And, zdrvhe, being a test routine, does not get called from
anywhere other than zchkaa, so I don't think there's a problem.

Mick
mickpont
 
Posts: 6
Joined: Wed Jul 18, 2007 4:31 am
Location: Oxford, UK

Re: Test routines ZDRVHEX, ZDRVSYX can seg fault

Postby Julien Langou » Wed Nov 30, 2011 12:19 pm

Hi Mick,

yes I think 150*NMAX will do ... ;)

( thanks )

Julien.

[code]
Author: langou
Date: Wed Nov 30 11:17:35 2011
New Revision: 1098

Log:

Change RWORK description in the header. The RWORK array needs to be at least of
dimension 2*NMAX to accomodate the calls to CHESVXX in CDRVHEX, ZHESVXX in
ZDRVHEX, CSYSVXX in CDRVSYX, and ZSYSVXX in ZDRVSYX. (The dimension of RWORK in
the caller subroutines --, e.g., ZCHKAA -- is way large enough.)

Modified:
lapack/trunk/TESTING/LIN/cdrvhex.f
lapack/trunk/TESTING/LIN/cdrvsyx.f
lapack/trunk/TESTING/LIN/zdrvhex.f
lapack/trunk/TESTING/LIN/zdrvsyx.f

[/code]
Julien Langou
 
Posts: 734
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA


Return to Bug report

Who is online

Users browsing this forum: Google [Bot] and 1 guest