As a followup to this question, I am looking for a solution to catch one of the errors thrown inside an OpenMP block and then re-throw it with the main thread after the OpenMP block when calling C++ code from R using Rcpp. The other question is about what is going wrong.
I have followed the answer here and tried with std::exception_ptr
. This seems to work on almost all platforms and compilers with the exception of Fedora with clang-11 using libc++. Here is an example:
// openmp-exception-issue.cpp
#include <omp.h>
#include <exception>
#include <stdexcept>
// [[Rcpp::plugins(openmp)]]
#include <Rcpp.h>
// [[Rcpp::export()]]
double that_cpp_func(int const n_it){
std::exception_ptr Ptr = nullptr;
bool is_set = false;
double out(0.);
#pragma omp parallel for num_threads(4) reduction(+:out)
for(int i = 0; i < n_it; ++i)
try
{
if(i > -1)
throw std::runtime_error("boh :(");
out += i;
}
catch (...)
{
#pragma omp critical
if(!is_set){
Ptr = std::current_exception();
is_set = true;
}
}
if(Ptr)
std::rethrow_exception(Ptr);
return out;
}
Running (you will need to change the path)
/root/R-devel/bin/R -d valgrind -e "Rcpp::sourceCpp('/sdir/openmp-exception-issue.cpp'); that_cpp_func(100)"
with the setup below yields the following:
==15467== Memcheck, a memory error detector
==15467== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==15467== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==15467== Command: /root/R-devel/bin/exec/R -e Rcpp::sourceCpp('/sdir/openmp-exception-issue.cpp');~+~that_cpp_func(100)
==15467==
R Under development (unstable) (2021-02-24 r80033) -- "Unsuffered Consequences"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...
> Rcpp::sourceCpp('/sdir/openmp-exception-issue.cpp'); that_cpp_func(100)
In file included from openmp-exception-issue.cpp:7:
In file included from /root/R-devel/library/Rcpp/include/Rcpp.h:57:
/root/R-devel/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable 'data' [-Wunused-variable]
SEXP data = Parent::get__();
^
1 warning generated.
==15467== Syscall param sched_setaffinity(mask) points to unaddressable byte(s)
==15467== at 0x550F55D: syscall (in /usr/lib64/libc-2.32.so)
==15467== by 0x539AD1C: ??? (in /usr/lib64/libomp.so)
==15467== by 0x536AAE9: ??? (in /usr/lib64/libomp.so)
==15467== by 0x535774A: ??? (in /usr/lib64/libomp.so)
==15467== by 0x5357B8C: ??? (in /usr/lib64/libomp.so)
==15467== by 0x10B0FB07: that_cpp_func(int) (openmp-exception-issue.cpp:10)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== by 0x4D50BC: Rf_eval (eval.c:830)
==15467== by 0x4EED11: R_execClosure (eval.c:0)
==15467== by 0x4EE288: Rf_applyClosure (eval.c:1823)
==15467== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==15467==
==15467== Invalid read of size 8
==15467== at 0x71EC2DF: __cxa_end_catch (in /usr/lib64/libstdc++.so.6.0.28)
==15467== by 0x10B0FE08: .omp_outlined._debug__ (openmp-exception-issue.cpp:30)
==15467== by 0x10B0FE08: .omp_outlined. (openmp-exception-issue.cpp:15)
==15467== by 0x53B27C2: __kmp_invoke_microtask (in /usr/lib64/libomp.so)
==15467== by 0x5358068: ??? (in /usr/lib64/libomp.so)
==15467== by 0x535BFF2: __kmp_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x534A740: __kmpc_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x10B0FB63: that_cpp_func(int) (openmp-exception-issue.cpp:15)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== by 0x4D50BC: Rf_eval (eval.c:830)
==15467== by 0x4EED11: R_execClosure (eval.c:0)
==15467== Address 0x99d3990 is 96 bytes inside a block of size 144 free'd
==15467== at 0x483A9F5: free (vg_replace_malloc.c:538)
==15467== by 0xB6AE48A: __cxa_decrement_exception_refcount (in /usr/lib64/libc++abi.so.1.0)
==15467== by 0x10B0FDE9: .omp_outlined._debug__ (openmp-exception-issue.cpp:27)
==15467== by 0x10B0FDE9: .omp_outlined. (openmp-exception-issue.cpp:15)
==15467== by 0x53B27C2: __kmp_invoke_microtask (in /usr/lib64/libomp.so)
==15467== by 0x5358068: ??? (in /usr/lib64/libomp.so)
==15467== by 0x535BFF2: __kmp_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x534A740: __kmpc_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x10B0FB63: that_cpp_func(int) (openmp-exception-issue.cpp:15)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== by 0x4D50BC: Rf_eval (eval.c:830)
==15467== Block was alloc'd at
==15467== at 0x4839809: malloc (vg_replace_malloc.c:307)
==15467== by 0x71EC0C3: __cxa_allocate_exception (in /usr/lib64/libstdc++.so.6.0.28)
==15467== by 0x10B0FD64: .omp_outlined._debug__ (openmp-exception-issue.cpp:20)
==15467== by 0x10B0FD64: .omp_outlined. (openmp-exception-issue.cpp:15)
==15467== by 0x53B27C2: __kmp_invoke_microtask (in /usr/lib64/libomp.so)
==15467== by 0x5358068: ??? (in /usr/lib64/libomp.so)
==15467== by 0x535BFF2: __kmp_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x534A740: __kmpc_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x10B0FB63: that_cpp_func(int) (openmp-exception-issue.cpp:15)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== by 0x4D50BC: Rf_eval (eval.c:830)
==15467==
10 more errors...
==15467==
==15467== Invalid free() / delete / delete[] / realloc()
==15467== at 0x483AEDD: operator delete(void*) (vg_replace_malloc.c:584)
==15467== by 0x72030FB: std::runtime_error::~runtime_error() (in /usr/lib64/libstdc++.so.6.0.28)
==15467== by 0xB6AE47E: __cxa_decrement_exception_refcount (in /usr/lib64/libc++abi.so.1.0)
==15467== by 0x10B0FBC0: that_cpp_func(int) (openmp-exception-issue.cpp:36)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== by 0x4D50BC: Rf_eval (eval.c:830)
==15467== by 0x4EED11: R_execClosure (eval.c:0)
==15467== by 0x4EE288: Rf_applyClosure (eval.c:1823)
==15467== by 0x4D512D: Rf_eval (eval.c:850)
==15467== by 0x523CC9: Rf_ReplIteration (main.c:264)
==15467== Address 0x9604a10 is 0 bytes inside a block of size 31 free'd
==15467== at 0x483AEDD: operator delete(void*) (vg_replace_malloc.c:584)
==15467== by 0x72030FB: std::runtime_error::~runtime_error() (in /usr/lib64/libstdc++.so.6.0.28)
==15467== by 0xB6AE47E: __cxa_decrement_exception_refcount (in /usr/lib64/libc++abi.so.1.0)
==15467== by 0x10B0FDE9: .omp_outlined._debug__ (openmp-exception-issue.cpp:27)
==15467== by 0x10B0FDE9: .omp_outlined. (openmp-exception-issue.cpp:15)
==15467== by 0x53B27C2: __kmp_invoke_microtask (in /usr/lib64/libomp.so)
==15467== by 0x5358068: ??? (in /usr/lib64/libomp.so)
==15467== by 0x535BFF2: __kmp_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x534A740: __kmpc_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x10B0FB63: that_cpp_func(int) (openmp-exception-issue.cpp:15)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== Block was alloc'd at
==15467== at 0x4839E7D: operator new(unsigned long) (vg_replace_malloc.c:342)
==15467== by 0x7213B20: ??? (in /usr/lib64/libstdc++.so.6.0.28)
==15467== by 0x7213CB6: ??? (in /usr/lib64/libstdc++.so.6.0.28)
==15467== by 0x721409D: std::runtime_error::runtime_error(char const*) (in /usr/lib64/libstdc++.so.6.0.28)
==15467== by 0x10B0FD72: .omp_outlined._debug__ (openmp-exception-issue.cpp:20)
==15467== by 0x10B0FD72: .omp_outlined. (openmp-exception-issue.cpp:15)
==15467== by 0x53B27C2: __kmp_invoke_microtask (in /usr/lib64/libomp.so)
==15467== by 0x5358068: ??? (in /usr/lib64/libomp.so)
==15467== by 0x535BFF2: __kmp_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x534A740: __kmpc_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x10B0FB63: that_cpp_func(int) (openmp-exception-issue.cpp:15)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467==
==15467== Invalid free() / delete / delete[] / realloc()
==15467== at 0x483A9F5: free (vg_replace_malloc.c:538)
==15467== by 0xB6AE48A: __cxa_decrement_exception_refcount (in /usr/lib64/libc++abi.so.1.0)
==15467== by 0x10B0FBC0: that_cpp_func(int) (openmp-exception-issue.cpp:36)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== by 0x4D50BC: Rf_eval (eval.c:830)
==15467== by 0x4EED11: R_execClosure (eval.c:0)
==15467== by 0x4EE288: Rf_applyClosure (eval.c:1823)
==15467== by 0x4D512D: Rf_eval (eval.c:850)
==15467== by 0x523CC9: Rf_ReplIteration (main.c:264)
==15467== by 0x52545F: R_ReplConsole (main.c:314)
==15467== Address 0x99d3930 is 0 bytes inside a block of size 144 free'd
==15467== at 0x483A9F5: free (vg_replace_malloc.c:538)
==15467== by 0xB6AE48A: __cxa_decrement_exception_refcount (in /usr/lib64/libc++abi.so.1.0)
==15467== by 0x10B0FDE9: .omp_outlined._debug__ (openmp-exception-issue.cpp:27)
==15467== by 0x10B0FDE9: .omp_outlined. (openmp-exception-issue.cpp:15)
==15467== by 0x53B27C2: __kmp_invoke_microtask (in /usr/lib64/libomp.so)
==15467== by 0x5358068: ??? (in /usr/lib64/libomp.so)
==15467== by 0x535BFF2: __kmp_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x534A740: __kmpc_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x10B0FB63: that_cpp_func(int) (openmp-exception-issue.cpp:15)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== by 0x4D50BC: Rf_eval (eval.c:830)
==15467== Block was alloc'd at
==15467== at 0x4839809: malloc (vg_replace_malloc.c:307)
==15467== by 0x71EC0C3: __cxa_allocate_exception (in /usr/lib64/libstdc++.so.6.0.28)
==15467== by 0x10B0FD64: .omp_outlined._debug__ (openmp-exception-issue.cpp:20)
==15467== by 0x10B0FD64: .omp_outlined. (openmp-exception-issue.cpp:15)
==15467== by 0x53B27C2: __kmp_invoke_microtask (in /usr/lib64/libomp.so)
==15467== by 0x5358068: ??? (in /usr/lib64/libomp.so)
==15467== by 0x535BFF2: __kmp_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x534A740: __kmpc_fork_call (in /usr/lib64/libomp.so)
==15467== by 0x10B0FB63: that_cpp_func(int) (openmp-exception-issue.cpp:15)
==15467== by 0x10B0FEAA: sourceCpp_1_that_cpp_func (openmp-exception-issue.cpp:47)
==15467== by 0x49DA3A: R_doDotCall (dotcode.c:598)
==15467== by 0x4A0510: do_dotcall (dotcode.c:1281)
==15467== by 0x4D50BC: Rf_eval (eval.c:830)
==15467==
1 more error...
Error in that_cpp_func(100) : c++ exception (unknown reason)
Calls: that_cpp_func -> .Call
Execution halted
==15467==
==15467== HEAP SUMMARY:
==15467== in use at exit: 55,351,131 bytes in 10,962 blocks
==15467== total heap usage: 30,797 allocs, 19,837 frees, 94,080,022 bytes allocated
==15467==
==15467== LEAK SUMMARY:
==15467== definitely lost: 0 bytes in 0 blocks
==15467== indirectly lost: 0 bytes in 0 blocks
==15467== possibly lost: 0 bytes in 0 blocks
==15467== still reachable: 55,351,131 bytes in 10,962 blocks
==15467== of which reachable via heuristic:
==15467== newarray : 4,264 bytes in 1 blocks
==15467== suppressed: 0 bytes in 0 blocks
==15467== Rerun with --leak-check=full to see details of leaked memory
==15467==
==15467== For lists of detected and suppressed errors, rerun with: -s
==15467== ERROR SUMMARY: 32 errors from 18 contexts (suppressed: 0 from 0)
It seems to work on all other platform and compiler configurations I have tested though. I have tried to make an example without Rcpp (a pure C++ example) but this does not produce the error shown above.
The motivating example is my mdgc package which yields the following error on CRAN's r-devel-linux-x86_64-fedora-clang:
*** caught segfault ***
address 0xffffffff, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...
This is consistent with the Valgrind output.
Update
You also get similar errors if you remove the #pragma omp parallel for num_threads(4) reduction(+:out)
and #pragma omp critical
. I.e. it is not related to OpenMP.
Producing the Result
I ran the following to produce the results (like CRAN's r-devel-linux-x86_64-fedora-clang):
sudo docker run -ti rhub/fedora-clang
export _R_CHECK_INSTALL_DEPENDS_=true
export _R_CHECK_SUGGESTS_ONLY_=true
export _R_CHECK_NO_RECOMMENDED_=true
export _R_CHECK_DOC_SIZES2_=true
export _R_CHECK_DEPRECATED_DEFUNCT_=true
export _R_CHECK_SCREEN_DEVICE_=warn
export _R_CHECK_REPLACING_IMPORTS_=true
export _R_CHECK_TOPLEVEL_FILES_=true
export _R_CHECK_DOT_FIRSTLIB_=true
export _R_CHECK_RD_LINE_WIDTHS_=true
export _R_CHECK_S3_METHODS_NOT_REGISTERED_=true
export _R_CHECK_OVERWRITE_REGISTERED_S3_METHODS_=true
export _R_CHECK_CODE_USAGE_WITH_ONLY_BASE_ATTACHED_=TRUE
export _R_CHECK_NATIVE_ROUTINE_REGISTRATION_=true
export _R_CHECK_FF_CALLS_=registration
export _R_CHECK_PRAGMAS_=true
export _R_CHECK_COMPILATION_FLAGS_=true
export _R_CHECK_R_DEPENDS_=true
export _R_CHECK_PACKAGES_USED_IN_TESTS_USE_SUBDIRS_=true
export _R_CHECK_SHLIB_OPENMP_FLAGS_=true
export _R_CHECK_CODE_ASSIGN_TO_GLOBALENV_=true
export _R_CHECK_CODE_DATA_INTO_GLOBALENV_=true
export _R_CHECK_PKG_SIZES_=true
export _R_CHECK_LIMIT_CORES_=true
#export _R_CHECK_LENGTH_1_CONDITION_ package:_R_CHECK_PACKAGE_NAME_,abort,verbose
export _R_S3_METHOD_LOOKUP_BASEENV_AFTER_GLOBALENV_=true
export _R_CHECK_AUTOCONF_=true
export _R_CHECK_THINGS_IN_CHECK_DIR_=true
export _R_CHECK_THINGS_IN_TEMP_DIR_=true
export _R_CHECK_THINGS_IN_TEMP_DIR_EXCLUDE_="^ompi"
export _R_CHECK_BASHISMS_=true
export _R_CHECK_ORPHANED_=true
export _R_CHECK_DEPENDS_ONLY_DATA_=true
export _R_CHECK_XREFS_PKGS_ARE_DECLARED_=true
yum install wget -y
yum install java-openjdk-devel -y
yum install libcxx-devel -y
yum install rsync -y
yum install openssl-devel -y
mkdir ~/.R
echo "MAKEFLAGS = -j 6" >> ~/.R/Makevars
cd
wget -c "https://stat.ethz.ch/R/daily/R-devel.tar.gz"
tar -zxvf R-devel.tar.gz
cd R-devel
tools/rsync-recommended
# check with https://www.stats.ox.ac.uk/pub/bdr/Rconfig/r-devel-linux-x86_64-fedora-clang
./configure \
CC="clang" \
CXX="clang++ -stdlib=libc++" \
FC=gfortran \
MAKEFLAGS="-j 6" \
CFLAGS="-g -O3 -Wall -pedantic" \
FFLAGS="-g -O2 -mtune=native -Wall -pedantic" \
CXXFLAGS="-g -O3 -Wall -pedantic -frtti" \
LDFLAGS="-L/usr/local/lib64" \
JAVA_HOME=/usr/lib/jvm/java-11
make
make install
echo "options(repos = structure(c(CRAN = 'http://cran.rstudio.com')))" >> ~/.Rprofile
/root/R-devel/bin/R -e "install.packages('Rcpp')"
# replace the path with your path to openmp-exception-issue.cpp
/root/R-devel/bin/R -d valgrind -e "Rcpp::sourceCpp('/sdir/openmp-exception-issue.cpp'); that_cpp_func(100)"
Using RcppThread
RcppThread equally fails. Consider the following file:
// openmp-exception-issue.cpp
#include <exception>
#include <stdexcept>
// [[Rcpp::depends(RcppThread)]]
#include <RcppThread.h>
// [[Rcpp::export()]]
double that_cpp_func(int const n_it){
std::exception_ptr Ptr = nullptr;
double out(0.);
RcppThread::ThreadPool pool(4);
for(int i = 0; i < n_it; ++i)
pool.push([&](int const j) -> void {
if(j > -1)
throw std::runtime_error("boh :(");
out += j; // ignore the race condition
}, i);
pool.join();
return out;
}
Running the example as before yields:
==139== Invalid read of size 8
==139== at 0x71EC2DF: __cxa_end_catch (in /usr/lib64/libstdc++.so.6.0.28)
==139== by 0x10B13351: RcppThread::ThreadPool::doJob(std::__1::function<void ()>&&) (ThreadPool.hpp:321)
==139== by 0x10B13201: RcppThread::ThreadPool::startWorker()::{lambda()#1}::operator()() const (ThreadPool.hpp:304)
==139== by 0x10B12F36: __invoke<(lambda at /root/R-devel/library/RcppThread/include/RcppThread/ThreadPool.hpp:279:27)> (type_traits:3899)
==139== by 0x10B12F36: __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /root/R-devel/library/RcppThread/include/RcppThread/ThreadPool.hpp:279:27)> (thread:280)
==139== by 0x10B12F36: void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, RcppThread::ThreadPool::startWorker()::{lambda()#1}> >(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, RcppThread::ThreadPool::startWorker()::{lambda()#1}>) (thread:291)
==139== by 0x53FA3F8: start_thread (in /usr/lib64/libpthread-2.32.so)
==139== by 0x5514B52: clone (in /usr/lib64/libc-2.32.so)
==139== Address 0x9151e90 is 96 bytes inside a block of size 144 free'd
==139== at 0x483A9F5: free (vg_replace_malloc.c:538)
==139== by 0xB6AE48A: __cxa_decrement_exception_refcount (in /usr/lib64/libc++abi.so.1.0)
==139== by 0x10B13344: RcppThread::ThreadPool::doJob(std::__1::function<void ()>&&) (ThreadPool.hpp:320)
==139== by 0x10B13201: RcppThread::ThreadPool::startWorker()::{lambda()#1}::operator()() const (ThreadPool.hpp:304)
==139== by 0x10B12F36: __invoke<(lambda at /root/R-devel/library/RcppThread/include/RcppThread/ThreadPool.hpp:279:27)> (type_traits:3899)
==139== by 0x10B12F36: __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /root/R-devel/library/RcppThread/include/RcppThread/ThreadPool.hpp:279:27)> (thread:280)
==139== by 0x10B12F36: void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, RcppThread::ThreadPool::startWorker()::{lambda()#1}> >(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, RcppThread::ThreadPool::startWorker()::{lambda()#1}>) (thread:291)
==139== by 0x53FA3F8: start_thread (in /usr/lib64/libpthread-2.32.so)
==139== by 0x5514B52: clone (in /usr/lib64/libc-2.32.so)
==139== Block was alloc'd at
==139== at 0x4839809: malloc (vg_replace_malloc.c:307)
==139== by 0x71EC0C3: __cxa_allocate_exception (in /usr/lib64/libstdc++.so.6.0.28)
==139== by 0x10B1240C: operator() (openmp-exception-issue.cpp:17)
==139== by 0x10B1240C: operator() (ThreadPool.hpp:129)
==139== by 0x10B1240C: __invoke<(lambda at /root/R-devel/library/RcppThread/include/RcppThread/ThreadPool.hpp:129:23) &> (type_traits:3899)
==139== by 0x10B1240C: __call<(lambda at /root/R-devel/library/RcppThread/include/RcppThread/ThreadPool.hpp:129:23) &> (__functional_base:348)
==139== by 0x10B1240C: operator() (functional:1557)
==139== by 0x10B1240C: std::__1::__function::__func<void RcppThread::ThreadPool::push<that_cpp_func(int)::$_0, int&>(that_cpp_func(int)::$_0&&, int&)::{lambda()#1}, std::__1::allocator<{lambda()#1}>, void ()>::operator()() (functional:1731)
==139== by 0x10B132FA: operator() (functional:1884)
==139== by 0x10B132FA: operator() (functional:2556)
==139== by 0x10B132FA: RcppThread::ThreadPool::doJob(std::__1::function<void ()>&&) (ThreadPool.hpp:317)
==139== by 0x10B13201: RcppThread::ThreadPool::startWorker()::{lambda()#1}::operator()() const (ThreadPool.hpp:304)
==139== by 0x10B12F36: __invoke<(lambda at /root/R-devel/library/RcppThread/include/RcppThread/ThreadPool.hpp:279:27)> (type_traits:3899)
==139== by 0x10B12F36: __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /root/R-devel/library/RcppThread/include/RcppThread/ThreadPool.hpp:279:27)> (thread:280)
==139== by 0x10B12F36: void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, RcppThread::ThreadPool::startWorker()::{lambda()#1}> >(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, RcppThread::ThreadPool::startWorker()::{lambda()#1}>) (thread:291)
==139== by 0x53FA3F8: start_thread (in /usr/lib64/libpthread-2.32.so)
==139== by 0x5514B52: clone (in /usr/lib64/libc-2.32.so)
...
This seems to be the same error:
- Invalid read at the end of the catch scope.
- Memory was free'd when using std::current_exception.