<br><br><div class="gmail_quote">On Thu, Sep 6, 2012 at 11:43 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
On 6 September 2012 at 21:24, Jiqiang Guo wrote:<br>
| Dear List,<br>
|<br>
| In the middle of figure out another problem, I used function Module twice, but<br>
| then I got segfault.  Is there any solution for this?  For the time being, I<br>
| really need to call function Module more than once.  <br>
<br>
</div>a) I simply never combine Rcpp modules with inline. With a package, things work. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
b) In<br>
<div class="im"><br>
      m <- Module("foo1", getDynLib(fx))<br>
      m2 <- Module("foo1", getDynLib(fx))<br>
<br>
</div>   are you by chance mistaking Module() [ ie the declaration ] with new() [<br>
   ie the instantiation of an object ] ?<br></blockquote><div>No. I am just trying to narrow down what causes the real problem I have. And I think now it is because I called Module a second time. Following Module call, I do have new .... </div>
<div><br></div><div>Anyway, the above a) and b) do not explain and solve the problem I have. </div><div>Thanks,</div><div><br></div><div>Jiqiang</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Dirk<br>
<div><div class="h5"><br>
<br>
| Best,<br>
| Jiqiang<br>
|<br>
| P.S. an example code and the dump of output.<br>
| In addition, my sessionInfo()<br>
|<br>
| > sessionInfo()<br>
| R version 2.15.1 (2012-06-22)<br>
| Platform: x86_64-pc-linux-gnu (64-bit)<br>
|<br>
| locale:<br>
|  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C             <br>
|  [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    <br>
|  [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8   <br>
|  [7] LC_PAPER=C                LC_NAME=C                <br>
|  [9] LC_ADDRESS=C              LC_TELEPHONE=C           <br>
| [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      <br>
|<br>
| attached base packages:<br>
| [1] stats     graphics  grDevices utils     datasets  methods   base  <br>
|   <br>
|<br>
| other attached packages:<br>
| [1] inline_0.3.8 Rcpp_0.9.13 <br>
|<br>
| loaded via a namespace (and not attached):<br>
| [1] tools_2.15.1<br>
|<br>
|<br>
| require("Rcpp")<br>
| require("inline")<br>
|<br>
| inc <- '<br>
| class Foo {<br>
| private:<br>
|   int x_;<br>
| public:<br>
|   Foo(int x) : x_(x) { } <br>
|   void setx(int x) { x_ = x;}<br>
|   int getx() const { return x_;}<br>
| }; <br>
|<br>
| RCPP_MODULE(foo1) {<br>
|   class_<Foo>("Foo")<br>
|   .constructor<int>() <br>
|   .method("setx", &Foo::setx) <br>
|   .method("getx", &Foo::getx) <br>
|   ;<br>
| }<br>
| '<br>
| fx <- cxxfunction(signature(), "", include = inc, plugin = "Rcpp", verbose = !<br>
| TRUE)<br>
| m <- Module("foo1", getDynLib(fx))<br>
| m2 <- Module("foo1", getDynLib(fx))<br>
|<br>
| ====== <br>
|<br>
| > m <- Module("foo1", getDynLib(fx))<br>
| > m2 <- Module("foo1", getDynLib(fx))<br>
| ><br>
| > f <- new(m$Foo, 1)<br>
| > f2 <- new(m2$Foo, 1)<br>
|<br>
|  *** caught segfault ***<br>
| address 0x90, cause 'memory not mapped'<br>
|<br>
| Traceback:<br>
|  1: .Call(symbol)<br>
|  2: Module(module, mustStart = TRUE)<br>
|  3: .getModulePointer(x)<br>
|  4: m2$Foo<br>
|  5: .getClassFromCache(Class, where)<br>
|  6: getClass(Class, where = topenv(parent.frame()))<br>
|  7: new(m2$Foo, 1)<br>
| aborting ...<br>
|<br>
|<br>
|<br>
</div></div>| ----------------------------------------------------------------------<br>
| _______________________________________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<span class="HOEnZb"><font color="#888888">--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
</font></span></blockquote></div><br>