SCM

[#6794] segfault for QR decomposition of a large dgTMatrix

Date:
2022-12-31 20:13
Priority:
3
State:
Open
Submitted by:
Ben Bolker (bbolker)
Assigned to:
Nobody (None)
Hardware:
None
Product:
None
Operating System:
None
Component:
None
Version:
None
Severity:
None
Resolution:
None
URL:
Summary:
segfault for QR decomposition of a large dgTMatrix

Detailed description
In trying to come up with a reproducible example for this SO question: https://stackoverflow.com/questions/74971430/qr-factorization-in-r-not-giving-correct-answer-with-large-sparse-matrix

... I instead managed to create a reproducible segfault example. This is with the most recent Matrix 1.5-4


```
set.seed(101)
library(Matrix)
d <- 173700
n <- 1e6
As <- sparseMatrix(i=integer(0),
j=integer(0),
dims = c(d, d), repr = "T")
As[cbind(sample(d, size = n, replace = TRUE),
sample(d, size = n, replace = TRUE))] <- rnorm(n)
bs <- sparseMatrix(i = 1:d, j = rep(1, d), x = rnorm(d))
qr_decomp <- qr(As, LAPACK = TRUE, tol = 1e-10)
```

address 0x557bb8913e50, cause 'memory not mapped'
Segmentation fault (core dumped)

R Under development (unstable) (2022-12-21 r83491)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 22.04 LTS

Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3; LAPACK version 3.10.0


Comments:

Message  ↓
Date: 2023-06-07 10:18
Sender: Martin Maechler

I can confirm this still has happened 3 days ago with the then most current "Matrix-devel" (pre 1.6-0) on a (Fedora 36) Linux (intel) platform.

Ditto for [#6778] (which probably *is* related).

Date: 2023-01-01 17:46
Sender: Mikael Jagan

dgTMatrix inherits its 'qr' method from virtual class sparseMatrix. That method just coerces to dgCMatrix and calls the corresponding method, which _doesn't_ take 'LAPACK' or 'tol' as arguments (they are silently ignored). So some red herrings here.

Anyway, could this be a duplicate of [#6778], another segfault for a large sparseMatrix? Hard to know until we get around to debugging dgCMatrix_QR() in src/dgCMatrix.c ... my new year's resolution ...

Attached Files:

Changes

No Changes Have Been Made to This Item

Thanks to:
Vienna University of Economics and Business Powered By FusionForge