[Rcpp-devel] Segmentation Fault on Exit of RInside-using Programs

Mario Bourgoin m.bourgoin at gmail.com
Fri Dec 7 18:56:32 CET 2012

Dear Sir or Madam,

I first noticed this problem yesterday.  Every C++ program that
instantiates RInside has a segmentation violation upon exit.  (That's after
doing everything it was supposed to do the way it was expected to do it.)
What am I doing wrong?

A minimal example is

#include <RInside.h>
int main(int argc, char *argv[]) {
    RInside R(argc, argv);


Ubuntu 10.04 LTS
R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Rcpp version 0.10.1
RInside version 0.2.10

To clear up the problem this morning, I nuked all R system code (sudo
apt-get remove r-base) and packages from my machine (sudo rm -rf
/usr/local/lib/R and other places).  I freshly installed R (sudo apt-get
install r-base) and the RInside package (> install.packages( 'RInside' )).
I copied the rinside_sample0.cpp and its Makefile into a fresh directory,
added ``CXXFLAGS:=$(filter-out -O3,$(CXXFLAGS))'' to the Makefile to
facilitate debugging, compiled

$ make rinside_sample0
g++ -I/usr/share/R/include -I/usr/local/lib/R/site-library/Rcpp/include
-I/usr/local/lib/R/site-library/RInside/include -pipe -g -Wall
rinside_sample0.cpp  -L/usr/lib64/R/lib -lR  -lblas -llapack
-L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp
-L/usr/local/lib/R/site-library/RInside/lib -lRInside
-Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib -o rinside_sample0

and ran the code to get

$ ./rinside_sample0
Segmentation fault

In gdb I get

$ gdb ./rinside_sample0
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/mob/src/example/rinside_sample0...done.
(gdb) run
Starting program: /home/mob/src/example/rinside_sample0
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff603e7af in ~Rostream (this=0x7ffff625cba0, __in_chrg=<value
optimized out>, __vtt_parm=<value optimized out>) at
41    ../inst/include/Rcpp/iostream/Rostream.h: No such file or directory.
    in ../inst/include/Rcpp/iostream/Rostream.h

I have downloaded the RInside and Rcpp sources and will reinstall them,
hopefully without -O3 and with -g so I can get more informative results.


Mario Bourgoin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121207/6e65ae84/attachment.html>

More information about the Rcpp-devel mailing list