Skip to content

Clang sanitizer error with tbb #2428

Closed
Closed
@SteveBronder

Description

@SteveBronder

Description

Adding the following to CXXFLAGS in make/local and running the profiling test (though I'm pretty sure this would fail with any test related to the tbb) gives an undefined behavior warning from the sanitizer

CXXFLAGS+=-fsanitize=undefined,address,leak -g -fno-omit-frame-pointer 
./runTests.py -j32 test/unit/math/rev/core/profiling_threading_test

Full err output here with the big bits being

lib/tbb_2019_U8/include/tbb/parallel_reduce.h:173:19: runtime error: member call on address 0x7f44453d3cc0 which does not point to an object of type 'tbb::task'
0x7f44453d3cc0: 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
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lib/tbb_2019_U8/include/tbb/parallel_reduce.h:173:19 in 
lib/tbb_2019_U8/include/tbb/task.h:735:9: runtime error: member call on address 0x7f44453d3cc0 which does not point to an object of type 'tbb::task'
0x7f44453d3cc0: 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
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lib/tbb_2019_U8/include/tbb/task.h:735:9 in 
lib/tbb_2019_U8/include/tbb/parallel_reduce.h:174:31: runtime error: member call on address 0x7f44453d3cc0 which does not point to an object of type 'tbb::task'
0x7f44453d3cc0: 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
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lib/tbb_2019_U8/include/tbb/parallel_reduce.h:174:31 in 

and

Direct leak of 2592 byte(s) in 9 object(s) allocated from:
    #0 0x4cff8d in operator new(unsigned long) (/home/steve/stan/origin/math/test/unit/math/rev/core/profiling_threading_test+0x4cff8d)
    #1 0x4de385 in stan::math::AutodiffStackSingleton<stan::math::vari_base, stan::math::chainable_alloc>::init() /home/steve/stan/origin/math/./stan/math/rev/core/autodiffstackstorage.hpp:125:19
    #2 0x4de2c2 in stan::math::AutodiffStackSingleton<stan::math::vari_base, stan::math::chainable_alloc>::AutodiffStackSingleton() /home/steve/stan/origin/math/./stan/math/rev/core/autodiffstackstorage.hpp:93:44
    #3 0x4d9446 in std::_MakeUniq<stan::math::AutodiffStackSingleton<stan::math::vari_base, stan::math::chainable_alloc> >::__single_object std::make_unique<stan::math::AutodiffStackSingleton<stan::math::vari_base, stan::math::chainable_alloc> >() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:962:34
    #4 0x4d7850 in stan::math::ad_tape_observer::on_scheduler_entry(bool) /home/steve/stan/origin/math/./stan/math/rev/core/init_chainablestack.hpp:46:29
    #5 0x7f4448f37508 in tbb::internal::observer_list::do_notify_entry_observers(tbb::internal::observer_proxy*&, bool) (/home/steve/stan/origin/math/lib/tbb/libtbb.so.2+0x29508)

This looks like it might be a tbb or sanitizer issue?

uxlfoundation/oneTBB#140

RcppCore/RcppParallel#36 (comment)

Expected Output

No UB or leaks

Current Version:

v4.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions