[Rcpp-devel] Segfault error during simulation in Rcpp
Dirk Eddelbuettel
edd at debian.org
Thu May 16 20:02:12 CEST 2013
Here is the self-contained example I asked for.
And yes, it crashes for me too. So let's not create 1e6 temp matrices.
Until someone has time to debug memory management internals. Which is really
hard, so this may not get fixed for a while. Sorry.
#!/usr/bin/Rscript
library(Rcpp)
myFun <- cppFunction('NumericMatrix myFun(NumericMatrix input, int n){
NumericMatrix A(n, n);
for(int Row = 0; Row < n; Row++) {
for(int Col = 0; Col < n; Col++) {
A(Row, Col) = input(Row, Col);
}
}
return A;
}')
n <- 10
x <- 1:n^2
N <- 1e6
b <- 0
for (j in 1:N) {
means <- matrix(x, n, n)
res <- myFun(means, n)
a <- res[1, 1]
b <- b + a
}
cat(sprintf("Done, b is %d\n", b))
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list