Skip to content

Failed assertion w/ASan on Linux and clang #1801

@nazavode

Description

@nazavode

Summary

This is the same issue reported in #1726 that was fixed for GCC by in #1782, but still reproduces for clang and derivatives:

$ /build/clang_18.1_cxx11_64_debug/test_task
[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
Assertion &stack_limit > stack_limit failed (located in the get_stack_attributes function, line in file: 177)
Detailed description: stack size must be positive
===============================================================================
test/tbb/test_task.cpp:124:
TEST CASE:  External threads sleep

test/tbb/test_task.cpp:124: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal

===============================================================================
[doctest] test cases: 1 | 0 passed | 1 failed | 17 skipped
[doctest] assertions: 0 | 0 passed | 0 failed |
[doctest] Status: FAILURE!
Aborted

Right now the stack size calculation via Posix calls (triggering the assertion on the ASan fake stack) is excluded by:

#if __linux__ && !__bg__ && !defined(__SANITIZE_ADDRESS__)

Unfortunately, the way to detect ASan changes across toolchains:

  • clang uses __has_feature, doesn't define __SANITIZE_ADDRESS__ (see here)
  • GCC defines __SANITIZE_ADDRESS__, doesn't support __has_feature (see here and here)

The behaviour of the __SANITIZE_ADDRESS__ macro across toolchains is shown here.

Version

8652376147e164ddd4190af417aab44940325488

Environment

  • Reproduces on Ubuntu 24.04 x86_64 with stock clang-18.

Steps To Reproduce

From 8652376147e164ddd4190af417aab44940325488:

$ cmake -S /src -B /build -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DTBB_SANITIZE=address
$ cmake --build /build
$ /build/clang_18.1_cxx11_64_debug/test_task

Docker reproducer:

FROM ubuntu:24.04

RUN apt-get update \
 && apt-get install -y --no-install-recommends \
        ninja-build \
        cmake \
        build-essential \
        clang \
        libclang-rt-18-dev \
        ca-certificates \
        git \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/uxlfoundation/oneTBB.git /oneTBB \
 && cd /oneTBB \
 && git checkout 8652376147e164ddd4190af417aab44940325488 \
 && cmake -S /oneTBB -B /build -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DTBB_SANITIZE=address \
 && cmake --build /build

CMD ["/build/clang_18.1_cxx11_64_debug/test_task"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions