[Rcpp-devel] segfault in Module...

Greg Minshall minshall at umich.edu
Mon Mar 4 23:54:00 CET 2013


hi.  the scenario is use cxxfunction to create a module, load it, use it
minimally, then *re*-load the module (by mistake -- well, actually,
after a failed compile of modified code), attempt to use it.  the result
is
----
 *** caught segfault ***
address 0xd8, cause 'memory not mapped'

Traceback:
 1: .Call(symbol)
 2: Module(module, mustStart = TRUE)
 3: .getModulePointer(x)
 4: cl$cluslist
----

here's the R/C++ code:
----
# the following crashes R with a segfault in Module.
require(Rcpp)
require(inline)

inc <- '
class cluslist {
public:
    int values;
};

using namespace Rcpp;
RCPP_MODULE(cluslist_module) {
    class_<cluslist>("cluslist") 
    .field("values", &cluslist::values)
        ;
}

// [[Rcpp::export]]
void foo() {}
'
clm <- cxxfunction(,plugin="Rcpp", include=inc)
cl <- Module("cluslist_module", getDynLib(clm))
cluslist <- cl$cluslist
cl<- new(cluslist)


cl <- Module("cluslist_module", getDynLib(clm))
cluslist <- cl$cluslist
----

cheers.


More information about the Rcpp-devel mailing list