Hi,
I met several segmentation faults in LAPACK TIMING programs. Both the
LAPACK and TIMING are the latest version and downloaded from the
http://www.netlib.org/lapack/. The segmentation faults happen in
xlintimc with input CTIME.in, xlintimd with input DTIME.in, xlintims
with input STIME.in and xlintimz with input ZTIME.in. I did some
debugging on these programs and found these segmentation faults may be
caused by array out of bounds.
Here is my analysis: ( I take the xlintimd and DTIME.in as the example )
1. The stack trace:
#0 dlaset at lapack3.2/SRC/dlaset.f:99
#1 0x00000000004a6fc6 in dlasda at lapack3.2/SRC/dlasda.f:278
#2 0x000000000046311e in dlalsd at lapack3.2/TIMING/LIN/LINSRC/dlalsd.f:351
#3 0x0000000000459776 in dgelsd at lapack3.2/TIMING/LIN/LINSRC/dgelsd.f:390
#4 0x00000000004294c2 in dtimls at lapack3.2/TIMING/LIN/dtimls.f:517
#5 0x00000000004134eb in MAIN__ at lapack3.2/TIMING/LIN/dtimaa.f:657
#6 0x00000000004f3fde in main ()
2. I found the problematic array is the IWORK. If we trace the usage
of IWORK from the top to bottom:
in TIMING/LIN/dtimaa.f, line 146:
146: IWORK (2*NMAXB)
Here, the IWORK will contain 10000 integer elements.
in TIMING/LIN/dlalsd.f, line 258 ~ 279 and 351:
258: NLVL = INT( LOG( DBLE( N ) / DBLE( SMLSIZ+1 ) ) / LOG(TWO ) ) + 1
274: SIZEI = 1 + N
275: K = SIZEI + N
276: GIVPTR = K + N
277: PERM = GIVPTR + N
278: GIVCOL = PERM + NLVL*N
279: IWK = GIVCOL + NLVL*N*2
351:
CALL DLASDA( ICMPQ1, SMLSIZ, NSIZE, SQRE, D( ST ),
$ E( ST ), WORK( U+ST1 ), N, WORK( VT+ST1 ),
$ IWORK( K+ST1 ), WORK( DIFL+ST1 ),
$ WORK( DIFR+ST1 ), WORK( Z+ST1 ),
$ WORK( POLES+ST1 ), IWORK( GIVPTR+ST1 ),
$ IWORK( GIVCOL+ST1 ), N, IWORK( PERM+ST1 ),
$ WORK( GIVNUM+ST1 ), WORK( C+ST1 ),
$ WORK( S+ST1 ), WORK( NWORK ), IWORK( IWK ),
$ INFO )
At this callsite, when N is 500 and SMLSIZ is 25, the value of NLVL is
5, SIZEI is 501, K is 1001, GIVPTR is 1501, PERM is 2001, GIVCOL is
4501, IWK is 9501. That means, the IWORK passed to DLASDA will have an
offset of 9501.
in SRC/dlasda.f, line 236 ~ 261:
236: INODE = 1
237: NDIML = INODE + N
238: NDIMR = NDIML + N
256: I1 = I  1
257: IC = IWORK( INODE+I1 )
258: NL = IWORK( NDIML+I1 )
261: NLF = IC  NL
If N is 500, NDIML will be 501, the accessing of IWORK(NDIML+I1) will
exceed the upper bound of the IWORK array. So that the value of NL
will be very strange, which cause the segmentation fault at last.
This problem exists in the IWORK array in LIN/ctimaa.f, LIN/dtimaa.f,
LIN/stimaa.f, LIN/ztimaa.f. This problem also exists in another array:
the RWORK in LIN/ctimaa.f and LIN/ztimaa.f.
Could some LAPACK or TIMING developers check my analysis, confirm this
issue and make changes to make them work? Thank you very much.

Regards,
Lai JianXin
