[Rcpp-devel] package using Rcpp aborting with: terminate called after throwing an instance of 'Rcpp::not_compatible' inside class__newInstance()

Simon Urbanek simon.urbanek at r-project.org
Thu Nov 19 20:19:54 CET 2015


One package (guitar) that happens to use Rcpp started breaking recently without any change to its own code as follows:

>  install.packages("guitar",,"http://rforge.net")
>  library(guitar)
>  Repository$new(".")
terminate called after throwing an instance of 'Rcpp::not_compatible'
  what():  expecting an external pointer
Aborted (core dumped)

Stack trace below - it is happening in Module.cpp class__newInstance(). The method being called is simply a static constructor:

class Repository: public CPPWrapperObjectTraits<Repository, git_repository>
{
public:
    explicit Repository(std::string path);


First, I wouldn't expect an abort - ideally if anything is wrong it should just raise an R error (aborts are much harder to trace - in particular since the original issue was deep in a chain of several packages so R traceback would be helpful). Second, XPtr gets called with R_NilValue inside class__newInstance() but I have no idea why since the Repository object looks legit:

> Repository
C++ class 'Repository' <0x7f934961be60>
Constructors:
    Repository(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)

Fields: No public fields exposed by this class

Methods: 
     SEXP commits(SEXP)  
           
[...]

Note that it aborts even before the constructor is called so no code from the Repository object is actually involved here - it's inside Rcpp.

I have inherited the code (so please no flames, I just have to fix it ;)), so any leads as to why it now breaks while it used to work just fine would be highly appreciated. The sources are at
https://github.com/s-u/guitar
and the above fails both on Ubuntu and OS X (tested with R 3.2.2 and Rcpp 0.12.1 and 0.12.2 respectively).

Thanks,
Simon

stack trace (based on Rcpp 0.12.2) and I have instrumented XPtr - the R object passed is simply R_NilValue:

libc++abi.dylib: terminating with uncaught exception of type Rcpp::not_compatible: expecting an external pointer
Process 8286 stopped
* thread #1: tid = 0x155af, 0x00007fff8cdf5866 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff8cdf5866 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill + 10:
-> 0x7fff8cdf5866:  jae    0x7fff8cdf5870            ; __pthread_kill + 20
   0x7fff8cdf5868:  movq   %rax, %rdi
   0x7fff8cdf586b:  jmp    0x7fff8cdf2175            ; cerror_nocancel
   0x7fff8cdf5870:  retq   
(lldb) bt
* thread #1: tid = 0x155af, 0x00007fff8cdf5866 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff8cdf5866 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff94a0a35c libsystem_pthread.dylib`pthread_kill + 92
    frame #2: 0x00007fff8e171b1a libsystem_c.dylib`abort + 125
    frame #3: 0x00007fff95267f31 libc++abi.dylib`abort_message + 257
    frame #4: 0x00007fff9528d93a libc++abi.dylib`default_terminate_handler() + 240
    frame #5: 0x00007fff95c28322 libobjc.A.dylib`_objc_terminate() + 124
    frame #6: 0x00007fff9528b1d1 libc++abi.dylib`std::__terminate(void (*)()) + 8
    frame #7: 0x00007fff9528ac5b libc++abi.dylib`__cxa_throw + 124
    frame #8: 0x00000001044d86df Rcpp.so`Rcpp::XPtr<Rcpp::Module, Rcpp::PreserveStorage, &(this=<unavailable>, x=<unavailable>, tag=<unavailable>, prot=<unavailable>))>::XPtr(SEXPREC*, SEXPREC*, SEXPREC*) + 319 at XPtr.h:67
    frame #9: 0x00000001044d67ed Rcpp.so`class__newInstance(SEXPREC*) [inlined] Rcpp::XPtr<Rcpp::Module, Rcpp::PreserveStorage, &(this=0x0000000100806378, x=<unavailable>, tag=<unavailable>, prot=<unavailable>))>::XPtr(SEXPREC*, SEXPREC*, SEXPREC*) + 77 at XPtr.h:71
    frame #10: 0x00000001044d67e2 Rcpp.so`class__newInstance(args=<unavailable>) + 66 at Module.cpp:140
    frame #11: 0x000000010007406a libR.dylib`do_External(call=<unavailable>, op=<unavailable>, args=<unavailable>, env=<unavailable>) + 378 at dotcode.c:548
[...]


More information about the Rcpp-devel mailing list