[Rcpp-devel] NumericVector crashes in dataptr

Dirk Eddelbuettel edd at debian.org
Wed May 7 21:12:02 CEST 2014


Hi Slava

On 7 May 2014 at 15:06, Slava Mazur wrote:
| Hi Dirk,
| 
| Thanks for the prompt attention to this issue. It does not have anything to do with boost: the following behaves the same way:

Yes, I said the same in my email.  I was ready to remove it, but it has
nothing to do with it.

| 
| #include <RInside.h>
| #include <Rcpp.h>
| 
| int main(int argc, char *argv[]) {
|     RInside Rinst(argc, argv);
|     const int N = 173;
|     double v[N];
|     std::fill(v, v+N, 0.0);
|     Rcpp::NumericVector x(v, v+N);
|     std::cout << "All good\n";
|     return 0;
| }
| 
| I tried to dig into it a little bit further and observed things that look strange to me. Execution eventually gets to the following code in Rcpp/routines.h[196:200]
| 
| inline void* dataptr(SEXP x){
|     typedef void* (*Fun)(SEXP) ;
|     static Fun fun = GET_CALLABLE("dataptr") ;
|     return fun(x) ; 
| } 
| 
| It seems that the "fun" pointer above points to the dataptr function itself and thus its call starts an unlimited recursion, which is confirmed by stepping through "return fun(x)" code in gdb.
| 
| It is interesting that if I recompile the same code with -DCOMPILING_RCPP the issue goes away. Is it an intended behavior? Please advise.

Have you by chance recently updated parts of R, Rcpp, RInside, ... but not
the others?

If you upgraded Rcpp from 0.10.* to 0.11.* you MUST rebuild ALL dependent
packages.

If you don't you get errors on startup.   

If you do, things tend to work, or else we by now have gotten thrown off CRAN
as those good folks test relentlessly too.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list