[Rcpp-devel] RInside destructor not working properly?
Christian Sigg
christian at sigg-iten.ch
Mon Aug 27 13:28:15 CEST 2012
The following program
#include <RInside.h>
void foo() {
RInside R;
}
void bar() {
RInside R;
}
int main(int argc, const char * argv[]) {
foo();
bar();
return 0;
}
produces a great number of the following two lines
Error: bad target context--should NEVER happen;
please bug.report() [R_run_onexits]
as output.
Question: Is the RInside destructor not working properly? I would have expected that both in foo() and bar(), an instance of R is created and then destroyed immediately, without producing any kind of output.
Context: I'm developing code that calls the OpenCV library from R, with the help of Rcpp. For rapid development and unit testing, I use RInside to set up the environment before calling my C++ function that calls into the OpenCV library. The above mentioned error appears when the second unit test again calls the RInside constructor to set up its test environment.
This is on OS X 10.7 with Xcode 4.4.1 (Apple LLVM Compiler 4.0) and the latest version of the command line tools. I use R 2.15.1 and RInside 0.2.7.
If I avoid calling RInside() twice in the same program, my code is running smoothly.
Thanks for any assistance,
Christian
More information about the Rcpp-devel
mailing list