[Rcpp-devel] Rcpp::wrap seg fault (when called with a NULL pointer)
Hi, thanks that you resolved this issue so fast.. Regards, Christoph
On 05/24/2011 06:21 PM, Dirk Eddelbuettel wrote:
On 24 May 2011 at 17:29, Christoph Bergmeir wrote:
| Hi,
|
| of course it's your decision, but I personally think that adding the check to the wrapper is a good idea. For now, I added the check everywhere in my code where I use a const char* with Rcpp::wrap.
Please try SVN revision 3030 which is now resilient to this particular case
of NULL:
edd at max:~$ r -p /tmp/nil.r
Loading required package: inline
Loading required package: methods
NULL
Bye
edd at max:~$ cat /tmp/nil.r
require(inline)
fun<- cxxfunction(signature(),plugin="Rcpp",body='
const char *ret = NULL;
return Rcpp::wrap(ret);
');
fun()
cat("Bye\n")
edd at max:~$
As I joked earlier, it won't help the next time NULL comes hiding as the
payload of another pointer, but at least const char* is now covered. I also
added two quick unit tests.
Thanks for alerting us to this. Segfaults are after all almost always bad.
Dirk
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)