[Rcpp-devel] using Rcpp function Module twice triggers segfault
Dirk Eddelbuettel
edd at debian.org
Fri Sep 7 13:40:33 CEST 2012
On 6 September 2012 at 23:51, Jiqiang Guo wrote:
|
|
| On Thu, Sep 6, 2012 at 11:43 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
|
|
| On 6 September 2012 at 21:24, Jiqiang Guo wrote:
| | 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.
|
| a) I simply never combine Rcpp modules with inline. With a package, things
| work.
|
|
| b) In
|
| m <- Module("foo1", getDynLib(fx))
| m2 <- Module("foo1", getDynLib(fx))
|
| are you by chance mistaking Module() [ ie the declaration ] with new()
| [
| ie the instantiation of an object ] ?
|
| 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 ....
|
| Anyway, the above a) and b) do not explain and solve the problem I have.
Use new() twice to create not two objects.
Dirk
| Thanks,
|
| Jiqiang
|
|
|
|
|
| Dirk
|
|
| | 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 ...
| |
| |
| |
| | ----------------------------------------------------------------------
| | _______________________________________________
| | Rcpp-devel mailing list
| | Rcpp-devel at lists.r-forge.r-project.org
| | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
| --
| Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
|
|
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list