[Rcpp-devel] Memory not mapped

Hideyoshi Maeda hideyoshi.maeda at gmail.com
Thu Feb 20 16:50:20 CET 2014

Hi I am trying to run a function I created in Rcpp, which is then sourced/compiled and executed in R.

The function is called “entryexitclock”.

and starts off as follows:

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
List entryexitclock( SEXP xts_obj_,int ent_col, int exit_col, double clock_limit, int init_pos) {
  // function takes in xts_obj_ (an xts object from R) and converts to a NumericMatrix
  Rcpp::NumericMatrix x(xts_obj_); 
  // Get the index and call v
  DatetimeVector v(NumericVector(RObject(xts_obj_).attr("index")));
  // The dimensions of rtn_xts are extracted
  int nr = x.nrow();

There is more code but I’m starting to doubt if its related to the rest of the code. I have a feeling it might be my use of SEXP but I’m not sure...

The compilation works fine, however “sometimes” the code works and sometimes the code doesn’t…

The error when it doesn't is as follows:

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

 1: .Primitive(".Call")(<pointer: 0x1044dde70>, xts_obj_, ent_col,     exit_col, clock_limit, init_pos)
 2: entryexitclock(k, 11, 12, 60 * 60, 0)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Any suggestions as to what I can do to make sure that this function works every time rather than just sometimes?


More information about the Rcpp-devel mailing list