Dear Rcpp developers,
I'm having trouble with a reproducible error when wrapping a big Eigen dense
matrix.
Rcpp::LogicalMatrix mat_out_bool = Rcpp::wrap(result);
Thread 1 "R" received signal SIGSEGV, Segmentation fault.
coerceToLogical (v=0x7fffa1a1c010) at coerce.c:441
Where 'result' is an Eigen::MatrixXi of size 472132x30, which is the result of
a sparse x dense matrix multiplication.
DenseMap result = visit_codes_sparse * map;
The backtrace begins:
#0 coerceToLogical (v=0x7fffa1a1c010) at coerce.c:441
#1 Rf_coerceVector (v=, type=) at coerce.c:1243
#2 0x7fffdc660515 in Rcpp::internal::basic_cast<10> (x=0x7fffa1a1c010) at
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h:66
#3 0x7fffdc65edc5 in Rcpp::internal::r_true_cast<10> (x=0x7fffa1a1c010) at
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h:95
#4 0x7fffdc664a9d in Rcpp::r_cast<10> (x=0x7fffa1a1c010) at
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h:163
#5 0x7fffdc666f99 in Rcpp::Matrix<10, Rcpp::PreserveStorage>::Matrix
(this=0x7fff23a0, x=0x7fffa1a1c010)
at /usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/Matrix.h:53
#6 0x7fffdc68603e in icd9Comorbid_alt_MatMul (icd9df=..., icd9Mapping=...,
visitId="visit_id", icd9Field="code", threads=8, chunk_size=256,
omp_chunk_size=1)
at comorbid_alt_MatMul.cpp:271
#7 0x7fffdc64a597 in _icd_icd9Comorbid_alt_MatMul_try
(icd9dfSEXP=0x58590cd8, icd9MappingSEXP=0x5839d9d0,
visitIdSEXP=0x5a25e2b8, icd9FieldSEXP=0x5c066298,
threadsSEXP=0x623279f8, chunk_sizeSEXP=0x586122e8,
omp_chunk_sizeSEXP=0x58612258) at RcppExports.cpp:347
I would love to give a small reproducible example, but at this point, I can
only trigger the problem with a big data set (which makes valgrind unreasonably
slow), and only by repeating the computation, as sometimes it does succeed. The
code is in the eigen-sparse branch of https://github.com/jackwasey/icd . I do
not expect anyone to download and debug my code (which FWIW compiles without
any warnings), but I would like to know whether, in principle, I am doing
something wrong with the integer to logical 'cast' when wrapping, or if this is
possibly an Rcpp or RcppEigen bug. I can induce the crash on a server with huge
amounts of RAM, and on Mac and Linux platforms, with and without OpenMP enabled.
Thanks,
Jack
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel