Skip to content

dorcsd2by1/uncsd2by1: avoid OOB access with zero rows#1291

Open
jschueller wants to merge 1 commit into
Reference-LAPACK:masterfrom
jschueller:issue549
Open

dorcsd2by1/uncsd2by1: avoid OOB access with zero rows#1291
jschueller wants to merge 1 commit into
Reference-LAPACK:masterfrom
jschueller:issue549

Conversation

@jschueller

Copy link
Copy Markdown
Contributor

When P=0 and M=Q (U2 is M-by-M, X21 is M-by-M and orthogonal), or P=M and M=Q (U1 is M-by-M, X11 is M-by-M and orthogonal), or Q=0, the minimal dimension R = MIN(P, M-P, Q, M-Q) is zero, so C and S are empty. In these degenerate cases the preceding code entered the R == P or R == M-P branch and called the bidiagonalization subroutines (SORBDB2/SORBDB3) which then accessed elements X21(I,I+1) or X11(I,I+1) out of bounds in the second DO loop (I = P+1, Q or I = M-P+1, Q).

Fix: handle R = 0 directly in the four driver routines before the case-dependent bidiagonalization path. The three trivial CSD cases are:

Q = 0: set U1 = I, U2 = I, return.
P = 0, M = Q: copy X21 to U2, set V1T = I, return.
P = M, M = Q: copy X11 to U1, set V1T = I, return.

All other R=0 configurations are non-standard and still fall through to the existing path (which may fail).

Fixes #549

When P=0 and M=Q (U2 is M-by-M, X21 is M-by-M and orthogonal),
or P=M and M=Q (U1 is M-by-M, X11 is M-by-M and orthogonal),
or Q=0, the minimal dimension R = MIN(P, M-P, Q, M-Q) is zero,
so C and S are empty.  In these degenerate cases the preceding
code entered the R == P or R == M-P branch and called the
bidiagonalization subroutines (SORBDB2/SORBDB3) which then
accessed elements X21(I,I+1) or X11(I,I+1) out of bounds in
the second DO loop (I = P+1, Q or I = M-P+1, Q).

Fix: handle R = 0 directly in the four driver routines before
the case-dependent bidiagonalization path.  The three trivial
CSD cases are:

  Q = 0:     set U1 = I, U2 = I, return.
  P = 0, M = Q:  copy X21 to U2, set V1T = I, return.
  P = M, M = Q:  copy X11 to U1, set V1T = I, return.

All other R=0 configurations are non-standard and still fall
through to the existing path (which may fail).

Fixes Reference-LAPACK#549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xUNCSD2BY1 does not handle submatrices with empty rows properly

2 participants