RcppParallel icon indicating copy to clipboard operation
RcppParallel copied to clipboard

TBB issues when CRAN runs tests on package

Open MurrayEfford opened this issue 3 years ago • 6 comments

Firstly, please direct me to a more suitable list if this is not where I should seek help with RcppParallel.

CRAN would like me to fix clang-ASAN and clang-UBSAN issues from RcppParallel when I submit packages 'secr' and 'openCR'. These are completely arcane to me. The problem only seems to arise when running tests. Is there a setting in RcppParallel >=5.1.1 that will get me through?

The test results are at https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-ASAN/secr/tests/testthat.Rout.fail and https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/openCR/tests/testthat.Rout

Here is a typical snippet from the first:

library(testthat) test_check("secr") Loading required package: secr This is secr 4.4.1. For overview type ?secr ../../src/tbb/scheduler.cpp:328:16: runtime error: member call on address 0x7f795c81ff40 which does not point to an object of type 'tbb::task' 0x7f795c81ff40: note: object has invalid vptr 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Thanks Murray

MurrayEfford avatar May 04 '21 05:05 MurrayEfford

Your best hope is to disable TBB when testing on CRAN. This can be done by setting the environment variable

Sys.setenv(RCPP_PARALLEL_BACKEND = "tinythread")

in your tests. Unfortunately the TBB library does a variety of things that trip the ASAN / UBSAN checkers on CRAN and there's really just not much I can do about it.

kevinushey avatar May 04 '21 06:05 kevinushey

Thanks for your prompt and very helpful response. I can easily do that.

MurrayEfford avatar May 04 '21 07:05 MurrayEfford

Hi @kevinushey, I encountered an error while trying to install RcppParallel. The package fail to compile with TBB

(tbb) Building TBB using bundled sources ...
make[1]: Entering directory `/tmp/RtmpbCHtDl/R.INSTALL198fd18d3795c/RcppParallel/src/tbb/src'
../build/common.inc:74: *** "" is not supported. Add build/.inc file with os-specific settings .  Stop.
make[1]: Leaving directory `/tmp/RtmpbCHtDl/R.INSTALL198fd18d3795c/RcppParallel/src/tbb/src'
make: *** [tbb] Error 2
ERROR: compilation failed for package ‘RcppParallel’

I was wondering if there is any compile flag to disable TBB and use tinythread only?

dipterix avatar Aug 24 '21 13:08 dipterix

If you supply -DRCPP_PARALLEL_USE_TBB=0 to the compiler during compilation, that should suffice. You might need to do that via Makevars. (It would be nice if RcppParallel made it easier to do via the configure script though.)

kevinushey avatar Aug 24 '21 17:08 kevinushey

I see... Does that mean I have to edit the makevars instead of using configure.args?

dipterix avatar Aug 24 '21 19:08 dipterix

It's a non-autoconf configure script calling R code.

If you take a hard look at it, maybe you propose a concise PR that would listen to an outer environment variable (or alike) to avoid hand edits? Not sure we have good precedents but there may be some somewhere...

eddelbuettel avatar Aug 24 '21 20:08 eddelbuettel