[Rcpp-devel] using Rcpp function Module twice triggers segfault

Jiqiang Guo guojq28 at gmail.com
Fri Sep 7 03:24:05 CEST 2012


Dear List,

In the middle of figure out another problem, I used function Module twice,
but then I got segfault.  Is there any solution for this?  For the time
being, I really need to call function Module more than once.

Best,
Jiqiang

P.S. an example code and the dump of output.
In addition, my sessionInfo()

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8
 [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=C                LC_NAME=C
 [9] LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] inline_0.3.8 Rcpp_0.9.13

loaded via a namespace (and not attached):
[1] tools_2.15.1


require("Rcpp")
require("inline")

inc <- '
class Foo {
private:
  int x_;
public:
  Foo(int x) : x_(x) { }
  void setx(int x) { x_ = x;}
  int getx() const { return x_;}
};

RCPP_MODULE(foo1) {
  class_<Foo>("Foo")
  .constructor<int>()
  .method("setx", &Foo::setx)
  .method("getx", &Foo::getx)
  ;
}
'
fx <- cxxfunction(signature(), "", include = inc, plugin = "Rcpp", verbose
= !TRUE)
m <- Module("foo1", getDynLib(fx))
m2 <- Module("foo1", getDynLib(fx))

======

> m <- Module("foo1", getDynLib(fx))
> m2 <- Module("foo1", getDynLib(fx))
>
> f <- new(m$Foo, 1)
> f2 <- new(m2$Foo, 1)

 *** caught segfault ***
address 0x90, cause 'memory not mapped'

Traceback:
 1: .Call(symbol)
 2: Module(module, mustStart = TRUE)
 3: .getModulePointer(x)
 4: m2$Foo
 5: .getClassFromCache(Class, where)
 6: getClass(Class, where = topenv(parent.frame()))
 7: new(m2$Foo, 1)
aborting ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120906/89af7531/attachment.html>


More information about the Rcpp-devel mailing list