Skip to content

terminate called without an active exception #61

Closed
@bjmt

Description

@bjmt

Hi,

Thanks for the great package. Recently someone trying out one of my packages (which makes use of RcppThread) had R crash whenever they invoked a function which made use of RcppThread::parallelFor, with only this message: terminate called without an active exception. This error appears to be setup-specific, as I have been able to replicate the error on CentOS 7 (same as what the person who reported this me was using) with gcc 11.1.0, but not any other system I have access to. The following minimal example is enough to trigger the crash:

Rcpp::cppFunction('void func() {
  RcppThread::ProgressBar bar(20, 1);
  RcppThread::parallelFor(0, 20, [&] (int i) {
        std::this_thread::sleep_for(std::chrono::milliseconds(200));
        bar++;
    });
}', depends = "RcppThread", plugins = "cpp11")

func()

Running R with gdb, I can see the following backtrace:

(gdb) bt
#0  0x00007ffff6d47387 in raise () from /lib64/libc.so.6
#1  0x00007ffff6d48a78 in abort () from /lib64/libc.so.6
#2  0x00007ffff0ba64ee in __gnu_cxx::__verbose_terminate_handler() [clone .cold] ()
   from /opt/rh7/gcc/gcc-11.1.0/lib64/libstdc++.so.6
#3  0x00007ffff0bb1856 in __cxxabiv1::__terminate(void (*)()) ()
   from /opt/rh7/gcc/gcc-11.1.0/lib64/libstdc++.so.6
#4  0x00007ffff0bb18c1 in std::terminate() () from /opt/rh7/gcc/gcc-11.1.0/lib64/libstdc++.so.6
#5  0x00007fffe37065b5 in RcppThread::ThreadPool::globalInstance() ()
   from /tmp/RtmpK0p2Ry/sourceCpp-x86_64-pc-linux-gnu-1.0.7/sourcecpp_63b02386216/sourceCpp_2.so
#6  0x00007fffe3700309 in func() ()
   from /tmp/RtmpK0p2Ry/sourceCpp-x86_64-pc-linux-gnu-1.0.7/sourcecpp_63b02386216/sourceCpp_2.so
#7  0x00007fffe37009d0 in sourceCpp_1_func ()
   from /tmp/RtmpK0p2Ry/sourceCpp-x86_64-pc-linux-gnu-1.0.7/sourcecpp_63b02386216/sourceCpp_2.so
#8  0x00007ffff7840194 in R_doDotCall (ofun=<optimized out>, nargs=<optimized out>, cargs=<optimized out>, 
    call=0x167ebf0) at dotcode.c:595
#9  0x00007ffff784078d in do_dotcall (call=0x167ebf0, op=<optimized out>, args=<optimized out>, 
    env=<optimized out>) at dotcode.c:1280
#10 0x00007ffff788fd60 in Rf_eval (e=0x167ebf0, rho=rho@entry=0x158a348) at eval.c:826
#11 0x00007ffff7894438 in Rf_evalList (el=0x15fb090, rho=rho@entry=0x158a348, call=call@entry=0x15fb0c8, 
    n=1, n@entry=0) at eval.c:3054
#12 0x00007ffff788fc09 in Rf_eval (e=0x15fb0c8, rho=rho@entry=0x158a348) at eval.c:817
#13 0x00007ffff7890feb in R_execClosure (call=call@entry=0x158a1c0, newrho=newrho@entry=0x158a348, 
    sysparent=<optimized out>, rho=rho@entry=0x6535d8, arglist=arglist@entry=0x61b5b0, op=op@entry=0x15edb18)
    at eval.c:1888
#14 0x00007ffff7891d71 in Rf_applyClosure (call=call@entry=0x158a1c0, op=op@entry=0x15edb18, 
    arglist=arglist@entry=0x61b5b0, rho=rho@entry=0x6535d8, suppliedvars=<optimized out>) at eval.c:1814
#15 0x00007ffff788f8be in Rf_eval (e=e@entry=0x158a1c0, rho=rho@entry=0x6535d8) at eval.c:846
#16 0x00007ffff78c3842 in Rf_ReplIteration (rho=rho@entry=0x6535d8, savestack=savestack@entry=0, 
    browselevel=browselevel@entry=0, state=state@entry=0x7fffffffb940) at main.c:264
#17 0x00007ffff78c3ba1 in R_ReplConsole (rho=0x6535d8, savestack=0, browselevel=0) at main.c:314
#18 0x00007ffff78c3c3f in run_Rmainloop () at main.c:1113
#19 0x00007ffff78c3c82 in Rf_mainloop () at main.c:1120
#20 0x000000000040076b in main (ac=<optimized out>, av=<optimized out>) at Rmain.c:29

Unfortunately this is a bit beyond me. I'm not sure exactly what could be going wrong.

Walking back the commits, the last working one is 8725ca8; all future commits cause the crash (well except e6ab09d, as I get error during the compilation process).

If you don't have access to a similar system that can recreate the crash then please let me know if there is anything I do to provide more information. Here is my session info:

R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.3.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions