Skip to content
Back to formatted view

Raw Message

Message-ID: <19931.56073.758992.208514@max.nulle.part>
Date: 2011-05-24T16:21:29Z
From: Dirk Eddelbuettel
Subject: [Rcpp-devel] Rcpp::wrap seg fault (when called with a NULL	pointer)
In-Reply-To: <4DDBCED7.5040909@decsai.ugr.es>

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 

-- 
Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com