[Rcpp-devel] bigmatrix and segmentation fault due to 'memory not mapped'

Stefano Calza stecalza at gmail.com
Thu May 15 09:03:15 CEST 2014


Hi everybody,

I am trying to use big.matrix from Rcpp basically to write some 
(integer) data to a matrix.

I keep getting segmentation fault due to 'memory not mapped'.
Debugging with gdb I found out that the critical point is

MatrixAccessor<int> ma(*pBigMat);

The function is declared as something like (I just followed the Gallery 
Rcpp example):

RcppExport SEXP myFun(SEXP X, SEXP Y, SEXP Z, SEXP XX, XPtr<BigMatrix> 
pBigMat)

Basically it cannot get to the correct pointer.

The really weird thing is that this error happens ONLY using the 
function built within a package

.Call('myFun',X,Y,Z,XX,bigMat at address,package='myPackage')

BUT if I use the very same code, changing just the declaration

// [Rcpp::export]
IntegerVector myFun(SEXP X, SEXP Y, SEXP Z, SEXP XX, XPtr<BigMatrix> 
pBigMat)

and then

sourceCpp('mycode.cpp')

and

myFun(X,Y,Z,XX,bigMat at address)

it works fine!

So what am I doing wrong here? Is the pointer reset somehow? But why 
only when using .Call version?

Thanks

Stefano




More information about the Rcpp-devel mailing list