[Rcpp-devel] Rcpp::wrap seg fault (when called with a NULL pointer)

Christoph Bergmeir c.bergmeir at decsai.ugr.es
Tue May 24 13:22:59 CEST 2011


Hello everybody,

I just ran into the following problem: Using Rcpp::wrap with a NULL pointer crashes my R. I'm not so sure if this is a bug or if I'm using Rcpp::wrap in a way it shouldn't be used, so I wanted to discuss this here.

Here is some example code:

This works fine:
#-----------------------------------
library(inline)

src <- '
     const char* ret = "test";
     return Rcpp::wrap(ret);
     '

fun <- cxxfunction(signature(), src, plugin="Rcpp")
fun()
#-----------------------------------

Whereas this crashes R:
#-----------------------------------

src <- '
const char* ret = NULL;
return Rcpp::wrap(ret);
'

fun <- cxxfunction(signature(), src, plugin="Rcpp")
fun()
#-----------------------------------

I'm using Rcpp 0.9.4 and R.2.13, which I think are the latest versions.

Regards,
Christoph

PD: Dirk, Romain, I just read through the slides you made for this workshop a month ago. Great work! Thanks a lot!



-- 
Christoph Bergmeir
e-mail: c.bergmeir at decsai.ugr.es
Grupo SCI2S, DiCITS Lab          (http://sci2s.ugr.es/DiCITS)
Dpto. de Ciencias de la Computacion e Inteligencia Artificial
E.T.S. Ingenierias de Informatica y Telecomunicacion
Universidad de Granada
18071 - GRANADA (Spain)


More information about the Rcpp-devel mailing list