[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 =
R CMD build rcppapp1
R CMD INSTALL rcppapp1
R -q -e "require(Rcpp);require('rcppapp1');m1<-Module('yada',

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 =
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
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)

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [7] LC_PAPER=C                 LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=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
All text must be in a section
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'\'',
> require(Rcpp);require('rcppapp1');m1<-Module('yada',
Loading required package: Rcpp
Loading required package: rcppapp1

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

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

-------------- 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