Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Casts to avoid integer overflow in matrix row/columns. #1281

Merged
merged 7 commits into from Oct 27, 2023

Conversation

LTLA
Copy link
Contributor

@LTLA LTLA commented Oct 23, 2023

Pull Request Template for Rcpp

See #1280 for more details.

Checklist

  • Code compiles correctly
  • R CMD check still passes all tests
  • Preferably, new tests were added which fail without the change
  • Document the changes by file in ChangeLog

(Not sure how to add tests for this as the failure only occurs for very large matrices that aren't easy to create.)

@rekado
Copy link

rekado commented Oct 24, 2023

Would it be helpful to test this change in the context of the problem that led to the associated bug report? https://support.bioconductor.org/p/9154744/#9154759

We could create a Guix environment that replaces Rcpp with a variant that has this patch set applied, and run the same problematic code.

@eddelbuettel
Copy link
Member

Sure. You don't have to use Guix, docker e.g. with r2u makes this a breeze.

@rekado
Copy link

rekado commented Oct 24, 2023

Okay, we'll get back to you.

We're already using Guix, so for us it's just a matter of doing this:

guix shell -m manifest.scm --with-patch=r-rcpp=1281.patch

@eddelbuettel
Copy link
Member

Whatever floats your boat, and thanks for additional testing. I am about half-way through the reverse dependencies check I am running for Rcpp (on an old and slow machine).

@jonasfreimuth
Copy link

jonasfreimuth commented Oct 24, 2023

It seems like the problem persists. Running the same script as mentioned on the Bioconductor forum produces a segfault even with the patches applied. Running

guix shell --with-patch=r-rcpp="$HOME"/temp/1281_mod.patch r r-edger -- Rscript --vanilla ~/temp/test.R

in a new directory,

On this Guix
Generation 45   Oct 17 2023 18:02:11    (current)
  guix 7823c65
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 7823c6504082a0cfbd98beb301e041fb8bc4e44e
With this patch file

For compatability, the changelog patch was removed

From 1e1c1cdbc52088f4b53b81e66975a15651e84a89 Mon Sep 17 00:00:00 2001
From: LTLA <infinite.monkeys.with.keyboards@gmail.com>
Date: Sun, 22 Oct 2023 19:12:12 -0700
Subject: [PATCH 1/3] Casts to avoid integer overflow in matrix row/columns.

---
 inst/include/Rcpp/vector/MatrixColumn.h | 2 +-
 inst/include/Rcpp/vector/MatrixRow.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/inst/include/Rcpp/vector/MatrixColumn.h b/inst/include/Rcpp/vector/MatrixColumn.h
index d3f3144f5..4154b61be 100644
--- a/inst/include/Rcpp/vector/MatrixColumn.h
+++ b/inst/include/Rcpp/vector/MatrixColumn.h
@@ -129,7 +129,7 @@ class ConstMatrixColumn : public VectorBase<RTYPE,true,ConstMatrixColumn<RTYPE>

     ConstMatrixColumn( const MATRIX& parent, int i ) :
         n(parent.nrow()),
-        const_start(parent.begin() + i *n)
+        const_start(parent.begin() + static_cast<R_xlen_t>(i) * n)
     {
         if( i < 0 || i >= parent.ncol() ) {
             const char* fmt = "Column index is out of bounds: "
diff --git a/inst/include/Rcpp/vector/MatrixRow.h b/inst/include/Rcpp/vector/MatrixRow.h
index 5d575f9b2..3620a10d8 100644
--- a/inst/include/Rcpp/vector/MatrixRow.h
+++ b/inst/include/Rcpp/vector/MatrixRow.h
@@ -169,7 +169,7 @@ class MatrixRow : public VectorBase< RTYPE, true, MatrixRow<RTYPE> > {
     }

     inline reference operator[]( int i ) const {
-        return parent[ row + i * parent_nrow ] ;
+        return parent[ row + static_cast<R_xlen_t>(i) * parent_nrow ] ;
     }

     inline iterator begin(){


From 6707d64068abf4d603d0678e5bca7f002ede1c1d Mon Sep 17 00:00:00 2001
From: LTLA <infinite.monkeys.with.keyboards@gmail.com>
Date: Sun, 22 Oct 2023 19:21:42 -0700
Subject: [PATCH 3/3] Missed a few spots.

---
 inst/include/Rcpp/vector/MatrixRow.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/inst/include/Rcpp/vector/MatrixRow.h b/inst/include/Rcpp/vector/MatrixRow.h
index 3620a10d8..7cb22e4fd 100644
--- a/inst/include/Rcpp/vector/MatrixRow.h
+++ b/inst/include/Rcpp/vector/MatrixRow.h
@@ -208,7 +208,7 @@ class MatrixRow : public VectorBase< RTYPE, true, MatrixRow<RTYPE> > {

     inline int get_parent_index(int i) const {
         RCPP_DEBUG_4( "MatrixRow<%d>::get_parent_index(int = %d), parent_nrow = %d >> %d\n", RTYPE, i, parent_nrow, i*parent_nrow )
-        return i * parent_nrow ;
+        return static_cast<R_xlen_t>(i) * parent_nrow ;
     }
 } ;

@@ -310,7 +310,7 @@ class ConstMatrixRow : public VectorBase< RTYPE, true, ConstMatrixRow<RTYPE> > {
     {} ;

     inline const_reference operator[]( int i ) const {
-        return parent[ row + i * parent_nrow ] ;
+        return parent[ row + static_cast<R_xlen_t>(i) * parent_nrow ] ;
     }

     inline const_iterator begin() const {
@@ -333,7 +333,7 @@ class ConstMatrixRow : public VectorBase< RTYPE, true, ConstMatrixRow<RTYPE> > {

     inline int get_parent_index(int i) const {
         RCPP_DEBUG_4( "ConstMatrixRow<%d>::get_parent_index(int = %d), parent_nrow = %d >> %d\n", RTYPE, i, parent_nrow, i*parent_nrow )
-        return i * parent_nrow ;
+        return static_cast<R_xlen_t>(i) * parent_nrow ;
     }
 } ;
 }
And this `test.R` file
library("edgeR")

options("timeout" = 60 * 60)

download_raw <- F

if (download_raw) {
  library("Matrix")

  files_needed <- c(
    cells = "count_matrix_barcodes.tsv",
    genes = "count_matrix_genes.tsv",
    matrix = "count_matrix_sparse.mtx"
  )

  dl_url <- "ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE176nnn/GSE176078/suppl/GSE176078_Wu_etal_2021_BRCA_scRNASeq.tar.gz"
  dl_dest <- "wu_raw.tar"
  unpacked_dir_name <- "Wu_etal_2021_BRCA_scRNASeq/"

  needed_paths <- paste0(unpacked_dir_name, "/", files_needed)
  names(needed_paths) <- names(files_needed)

  if (!all(lapply(needed_paths, file.exists))) {
    download.file(url = dl_url, destfile = dl_dest)
    untar(dl_dest)
  }

  matrix <- Matrix::readMM(needed_paths["matrix"])

  matrix@Dimnames <- list(
    readLines(needed_paths["genes"]),
    readLines(needed_paths["cells"])
  )

  count_mat <- as.matrix(matrix)

  norm_factors <- edgeR::calcNormFactors(count_mat)

  save_crash_objs <- FALSE

  if (save_crash_objs) {
    saveRDS(
      list(
        count_mat = count_mat,
        norm_factors = norm_factors
      ),
      "wu_raw_crash_objs.RDS"
    )
  }
} else {
  dl_url <- "https://bimsbstatic.mdc-berlin.de/akalin/jfreige/wu_raw_crash_objs.RDS"
  dl_dest <- "wu_raw_crash_objs.RDS"
  if (!file.exists(dl_dest)) {
    download.file(url = dl_url, destfile = dl_dest)
  }

  crash_objs <- readRDS(dl_dest)
  count_mat <- crash_objs$count_mat
  norm_factors <- crash_objs$norm_factors
}

print(sessionInfo())

# This will generate a segmentation fault.
edgeR::cpm(count_mat, norm_factors * colSums(count_mat))

I still get this output:

substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://guix.bordeaux.inria.fr'... 100.0%
The following derivations will be built:
  /gnu/store/zdpak51zfi7k4yzn18hlmkawh06yq0y8-r-rcpp-1.0.11.drv
  /gnu/store/2gpafwv908z2h3f9xlz789sbqqa79fgy-Rcpp_1.0.11.tar.xz.drv
  /gnu/store/5smyzh0afiadxi46xyrzk64sfaxa16b6-r-edger-3.42.4.drv

building /gnu/store/2gpafwv908z2h3f9xlz789sbqqa79fgy-Rcpp_1.0.11.tar.xz.drv...
building /gnu/store/zdpak51zfi7k4yzn18hlmkawh06yq0y8-r-rcpp-1.0.11.drv...
building /gnu/store/5smyzh0afiadxi46xyrzk64sfaxa16b6-r-edger-3.42.4.drv...
The following derivation will be built:
  /gnu/store/mmd1nhipjplkadcr8rc5nan3wi3mji0y-profile.drv

applying 4 grafts for r-edger-3.42.4 ...
applying 4 grafts for r-rcpp-1.0.11 ...
building CA certificate bundle...
listing Emacs sub-directories...
building fonts directory...
generating GLib schema cache...
building directory of Info manuals...
building XDG desktop file cache...
building XDG MIME database...
building profile with 2 packages...
Loading required package: limma
trying URL 'https://bimsbstatic.mdc-berlin.de/akalin/jfreige/wu_raw_crash_objs.RDS'
Content type 'application/octet-stream' length 412819144 bytes (393.7 MB)
==================================================
downloaded 393.7 MB

R version 4.3.1 (2023-06-16)
Platform: x86_64-unknown-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS/LAPACK: /gnu/store/d94sxy6axgzd3xr6bnp49l4v1nqzf825-openblas-0.3.20/lib/libopenblasp-r0.3.20.so;  LAPACK version 3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Europe/Berlin
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] edgeR_3.42.4 limma_3.56.2

loaded via a namespace (and not attached):
[1] compiler_4.3.1 Rcpp_1.0.11    grid_4.3.1     locfit_1.5-9.8 lattice_0.21-9

 *** caught segfault ***
address 0x7fd38d4ff320, cause 'memory not mapped'

Traceback:
 1: cpm.default(count_mat, norm_factors * colSums(count_mat))
 2: edgeR::cpm(count_mat, norm_factors * colSums(count_mat))
An irrecoverable exception occurred. R is aborting now ...

@eddelbuettel
Copy link
Member

Please sort that out with yourself. Rcpp does not explicitly support Guix. I can assert that a) it tests fine here and b) has by now been reverse-dependency tested against about 1500 of the 2700+ reverse dependencies. While I appreciate the input I am not sure it adds much to the issue at hand. (Also consider checking out @LTLA 's branch rather than just tossing a diff in. It;s what I do -- testing the main branch of the repo, and including the proposed PR changes to it.)

@eddelbuettel
Copy link
Member

Also, 1 TB is a lot of RAM. Maybe that is also beyond the scope of what the PR supports. I haven't done the napkin math. Can R itself assign a matrix in the dimensions you desire?

@jonasfreimuth
Copy link

jonasfreimuth commented Oct 24, 2023

Also, 1 TB is a lot of RAM. Maybe that is also beyond the scope of what the PR supports. I haven't done the napkin math. Can R itself assign a matrix in the dimensions you desire?

Well the actual computation doesn't require the whole memory before it fails. I merely mentioned it to point out that it was unlikely that the process ran into an error due to a hard limitation on available memory in the system.

From my (pretty limited) understanding of the C++ code that is being called in edgeR at the time around the segfault, nothing much beyond the input matrix and some wrapper thingy around an array of the same length as the number of the matrix' columns is in the memory and nothing seems to happen to balloon the amount of RAM used. And holding the initial matrix and that array in memory are no problems at all.

A generic double matrix of the same dimensions as the one used in the compuation takes about 22.2 GB of RAM. By the very rudimentary process of starting the script and looking at the used memory, it seems that about 30 GB of RAM are consumed before the segfault happens. To me that seems a reasonable amount to expect R not to collapse.

But yeah, I can't dispute that the original issue in #1280 appears to be fixed by this and this discussion might better be continued downstream in edgeR or the forum.

@Enchufa2
Copy link
Member

@eddelbuettel I ran @jonasfreimuth's test case in a machine with 126 GB of RAM and it

  • succeeds without this patch (!?);
  • segfaults with this patch.

So I think we should take a closer look at this.

@jonasfreimuth That said, we cannot work with a test case involving another package.

@eddelbuettel
Copy link
Member

Thanks for that, @Enchufa2 . Paging @LTLA then for comments on his patch...

@jonasfreimuth
Copy link

jonasfreimuth commented Oct 24, 2023

That said, we cannot work with a test case involving another package.

In the meantime I ran the example laid out in #1280, for me it fails both with and without the patches (via Guix). I will add the runs with session info in an edit.

Edit

Without patches:

guix shell r r-rcpp -- Rscript --vanilla 1280_example.R

1280_example.R
library("Rcpp")

sessionInfo()

b <- Rcpp::sourceCpp(code="
#include \"Rcpp.h\"

//[[Rcpp::export(rng=false)]]
double get_bottom_right(Rcpp::NumericMatrix x) {
    auto row = x.row(x.nrow() - 1);
    return row[x.ncol() - 1];
}
")

# Okay:
mat1 <- matrix(1:20000 + 0.0, nrow=20000, ncol=1e5)
get_bottom_right(mat1)
## [1] 20000
mat1[20000,1e5]
## [1] 20000

# Incorrect:
mat2 <- matrix(1:30000 + 0.0, nrow=30000, ncol=1e5)
get_bottom_right(mat2)
## [1] 13216

# Segfaults for me
mat2[30000,1e5]
Output
R version 4.3.1 (2023-06-16)
Platform: x86_64-unknown-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS/LAPACK: /gnu/store/d94sxy6axgzd3xr6bnp49l4v1nqzf825-openblas-0.3.20/lib/libopenblasp-r0.3.20.so;  LAPACK version 3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Europe/Berlin
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] Rcpp_1.0.11

loaded via a namespace (and not attached):
[1] compiler_4.3.1
[1] 20000
[1] 20000

 *** caught segfault ***
address 0x7f90edd13038, cause 'memory not mapped'

Traceback:
 1: get_bottom_right(mat2)
An irrecoverable exception occurred. R is aborting now ...

guix shell r -f packages.scm -- Rscript --vanilla 1280_example.R

packages.scm(define-module (packages) #:use-module (gnu) #:use-module (guix) #:use-module (guix git-download) #:use-module (guix hg-download) #:use-module (guix build-system r) #:use-module (guix licenses)) (define-public r-rcpp (let ((commit "6707d64068abf4d603d0678e5bca7f002ede1c1d") (revision "1")) (package (name "r-rcpp") (version (git-version "1.0.11.2" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/LTLA/Rcpp/") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "0ghr1n9jj9yi7cgc49532zk7n1i54wm5ahkmpj3r1bkxqkv93fc6")))) (properties `((upstream-name . "Rcpp"))) (build-system r-build-system) (home-page "https://github.com/LTLA/Rcpp/") (synopsis "Seamless R and C++ Integration") (description "The Rcpp package provides R functions as well as C++ classes which offer a seamless integration of R and C++. Many R data types and objects can be mapped back and forth to C++ equivalents which facilitates both writing of new code as well as easier integration of third-party libraries. Documentation about Rcpp is provided by several vignettes included in this package, via the Rcpp Gallery site at <https://gallery.rcpp.org>, the paper by Eddelbuettel and Francois (2011, <doi:10.18637/jss.v040.i08>), the book by Eddelbuettel (2013, <doi:10.1007/978-1-4614-6868-4>) and the paper by Eddelbuettel and Balamuta (2018, <doi:10.1080/00031305.2017.1375990>); see citation(\"Rcpp\") for details.") (license gpl2+)))) r-rcpp
Install output for the curious
starting phase `install'
* installing *source* package ‘Rcpp’ ...
** using staged installation
** libs
using C++ compiler: ‘g++ (GCC) 11.3.0’
g++ -std=gnu++17 -I"/gnu/store/1jxmimp2fv9620kxhm7m7yy8wr0xd7ny-r-minimal-4.3.1/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -g -O2  -c api.cpp -o api.o
g++ -std=gnu++17 -I"/gnu/store/1jxmimp2fv9620kxhm7m7yy8wr0xd7ny-r-minimal-4.3.1/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -g -O2  -c attributes.cpp -o attributes.o
g++ -std=gnu++17 -I"/gnu/store/1jxmimp2fv9620kxhm7m7yy8wr0xd7ny-r-minimal-4.3.1/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -g -O2  -c barrier.cpp -o barrier.o
g++ -std=gnu++17 -I"/gnu/store/1jxmimp2fv9620kxhm7m7yy8wr0xd7ny-r-minimal-4.3.1/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -g -O2  -c date.cpp -o date.o
g++ -std=gnu++17 -I"/gnu/store/1jxmimp2fv9620kxhm7m7yy8wr0xd7ny-r-minimal-4.3.1/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -g -O2  -c module.cpp -o module.o
g++ -std=gnu++17 -I"/gnu/store/1jxmimp2fv9620kxhm7m7yy8wr0xd7ny-r-minimal-4.3.1/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -g -O2  -c rcpp_init.cpp -o rcpp_init.o
g++ -std=gnu++17 -shared -L/gnu/store/1jxmimp2fv9620kxhm7m7yy8wr0xd7ny-r-minimal-4.3.1/lib/R/lib -L/usr/local/lib -o Rcpp.so api.o attributes.o barrier.o date.o module.o rcpp_init.o -L/gnu/store/1jxmimp2fv9620kxhm7m7yy8wr0xd7ny-r-minimal-4.3.1/lib/R/lib -lR
installing to /gnu/store/6fg6kx19dg4ak72achhja6w0606vy0vh-r-rcpp-1.0.11.2-1.6707d64/site-library/00LOCK-source/00new/Rcpp/libs
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
code for methods in class “C++OverloadedMethods” was not checked for suspicious field assignments (recommended package ‘codetools’ not available?)
code for methods in class “RcppClass” was not checked for suspicious field assignments (recommended package ‘codetools’ not available?)
code for methods in class “RcppClass” was not checked for suspicious field assignments (recommended package ‘codetools’ not available?)
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (Rcpp)
Output
R version 4.3.1 (2023-06-16)
Platform: x86_64-unknown-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS/LAPACK: /gnu/store/d94sxy6axgzd3xr6bnp49l4v1nqzf825-openblas-0.3.20/lib/libopenblasp-r0.3.20.so;  LAPACK version 3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Europe/Berlin
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] Rcpp_1.0.11

loaded via a namespace (and not attached):
[1] compiler_4.3.1
[1] 20000
[1] 20000

 *** caught segfault ***
address 0x7f9709bc9038, cause 'memory not mapped'

Traceback:
 1: get_bottom_right(mat2)
An irrecoverable exception occurred. R is aborting now ...

@jonasfreimuth
Copy link

No improvement on my end on 54245b1...

Updated packages.scm ``` (define-module (packages) #:use-module (gnu) #:use-module (guix) #:use-module (guix git-download) #:use-module (guix hg-download) #:use-module (guix build-system r) #:use-module (guix licenses))

(define-public r-rcpp
(let ((commit "54245b1f0710f7a1eded9e6d2e229b4875fcac36")
(revision "1"))
(package
(name "r-rcpp")
(version (git-version "1.0.11.2" revision commit))
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/LTLA/Rcpp/")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32 "1wwqip706v2zq1hvishr2yg7z1gajp2hf42f97qj46bnd7d18fw7"))))
(properties `((upstream-name . "Rcpp")))
(build-system r-build-system)
(home-page "https://github.com/LTLA/Rcpp/")
(synopsis "Seamless R and C++ Integration")
(description
"The Rcpp package provides R functions as well as C++ classes which offer a
seamless integration of R and C++. Many R data types and objects can be mapped
back and forth to C++ equivalents which facilitates both writing of new code as
well as easier integration of third-party libraries. Documentation about Rcpp
is provided by several vignettes included in this package, via the Rcpp Gallery
site at https://gallery.rcpp.org, the paper by Eddelbuettel and Francois
(2011, doi:10.18637/jss.v040.i08), the book by Eddelbuettel (2013,
doi:10.1007/978-1-4614-6868-4) and the paper by Eddelbuettel and Balamuta
(2018, doi:10.1080/00031305.2017.1375990); see citation("Rcpp") for details.")
(license gpl2+))))

r-rcpp

</details>

@LTLA
Copy link
Contributor Author

LTLA commented Oct 24, 2023

Still working on it, hold on.

@jonasfreimuth
Copy link

Sorry, didn't mean to rush 😅

@LTLA
Copy link
Contributor Author

LTLA commented Oct 24, 2023

I think that does it. The edgeR breakage was not (just) because of the overflow in MatrixRow, but also because there was an odd cast to int in VECTOR::end(). I removed it in 338c5b8 and now it seems happy - hopefully it doesn't break something else.

@rekado
Copy link

rekado commented Oct 24, 2023

Thank you! With the latest change I can no longer reproduce the segfault --- neither in the simplified example nor in the real-world use case.

Guix invocation used guix shell -C --network \ --with-git-url=r-rcpp=https://github.com/LTLA/Rcpp \ --with-commit=r-rcpp=338c5b8db93d4960b4c1f5c0df52e239b2ba890b \ --emulate-fhs \ bash make gcc-toolchain@11 r r-edger gdb

@eddelbuettel
Copy link
Member

I'll run another full reverse-depends check once the current one finishes.

@jonasfreimuth
Copy link

Yes, thanks indeed!

@Enchufa2
Copy link
Member

All good here. If the revdep check comes out clean, I think we're good to go.

@LTLA Please don't forget to update the Changelog with the latest changes.

@eddelbuettel
Copy link
Member

Yes update from here: first run, once all dependencies were taken care of, had only one potentially suspicious segfault. Second run ongoing, looks very good, the one segfault returned 😢 but did not replicate on another machines. So I think this may be local to the test machine. Package in question is MatchIt and it loads a metric ton, likely on of those packages needs a rebuild because something else (Matrix maybe) changed again.

@LTLA LTLA marked this pull request as ready for review October 26, 2023 19:07
@eddelbuettel
Copy link
Member

No new issues in second run -- so big big Thank You! to @LTLA for the PR. Will fold it in.

@eddelbuettel eddelbuettel merged commit 8575b2e into RcppCore:master Oct 27, 2023
7 checks passed
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.

None yet

5 participants