[Rcpp-devel] segfault for simple Rcpp module

Jiqiang Guo guojq28 at gmail.com
Sat May 5 06:51:09 CEST 2012


I was learning Rcpp and got the following problem in a basic example.
I have searched online and knew someone have the same problem before,
but did not find a good answer for this.

Simply put, I am running the following script:

rm -rf rcppapp1
R -q -e "library(Rcpp); Rcpp.package.skeleton(name = 'rcppapp1', module =
TRUE);sessionInfo()"
R CMD build rcppapp1
R CMD INSTALL rcppapp1
R -q -e "require(Rcpp);require('rcppapp1');m1<-Module('yada',
'rcppapp1');m1\$hello()"


But I could not run the hello function defined in the model yada.
Here is the output:

+ rm -rf rcppapp1
+ R -q -e 'library(Rcpp); Rcpp.package.skeleton(name = '\''rcppapp1'\'',
module = TRUE);sessionInfo()'
> library(Rcpp); Rcpp.package.skeleton(name = 'rcppapp1', module =
TRUE);sessionInfo()
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './rcppapp1/Read-and-delete-me'.

Adding Rcpp settings
 >> added RcppModules: yada
 >> added Depends: Rcpp
 >> added LinkingTo: Rcpp
 >> added useDynLib directive to NAMESPACE
 >> added Makevars file with Rcpp settings
 >> added Makevars.win file with Rcpp settings
 >> added example header file using Rcpp classes
 >> added example src file using Rcpp classes
 >> added example R file calling the C++ example
 >> added Rd file for rcpp_hello_world
 >> copied the example module
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-linux-gnu (64-bit)

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

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

other attached packages:
[1] Rcpp_0.9.10
>
>
+ R CMD build rcppapp1
* checking for file ‘rcppapp1/DESCRIPTION’ ... OK
* preparing ‘rcppapp1’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building ‘rcppapp1_1.0.tar.gz’

+ R CMD INSTALL rcppapp1
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘rcppapp1’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -O3 -pipe  -g  -c
rcpp_hello_world.cpp -o rcpp_hello_world.o
g++ -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -O3 -pipe  -g  -c
rcpp_module.cpp -o rcpp_module.o
g++ -shared -o rcppapp1.so rcpp_hello_world.o rcpp_module.o
-L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp
-Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/rcppapp1/libs
** R
** preparing package for lazy loading
** help
Warning:
/home/jq/Desktop/bitbucket/yabbrep/myrstan/rcppapp1/man/rcppapp1-package.Rd:31:
All text must be in a section
Warning:
/home/jq/Desktop/bitbucket/yabbrep/myrstan/rcppapp1/man/rcppapp1-package.Rd:32:
All text must be in a section
*** installing help indices
** building package indices
** testing if installed package can be loaded

* DONE (rcppapp1)
+ R -q -e 'require(Rcpp);require('\''rcppapp1'\'');m1<-Module('\''yada'\'',
'\''rcppapp1'\'');m1$hello()'
> require(Rcpp);require('rcppapp1');m1<-Module('yada',
'rcppapp1');m1$hello()
Loading required package: Rcpp
Loading required package: rcppapp1

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

Traceback:
 1: .Call(symbol)
 2: Module(module, mustStart = TRUE)
 3: .getModulePointer(x)
 4: m1$hello
aborting ...


Thanks!
J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120505/af2daf1d/attachment.html>


More information about the Rcpp-devel mailing list