Skip to content

sanitize/tsan_interface.h is NOT modules friendly #164216

@pinskia

Description

@pinskia

fowarded from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122344.

GCC's libstdc++'s memory includes sanitize/tsan_interface.h if thread sanitizer is turned on BUT if you use memory in a modules to export anything, GCC 15+ errors out due to TU-local entities being in use:

error: 'template<class _Tp> std::_Sp_atomic< <template-parameter-1-1> >::_Atomic_count::~_Atomic_count()' exposes TU-local entity '__tsan_mutex_not_static'
tsan_interface.h:50:23: note: '__tsan_mutex_not_static' declared with internal linkage
50 | static const unsigned __tsan_mutex_not_static = 1 << 8;

That is __tsan_mutex_not_static is not modules friendly.
None of the following are:

// Mutex has static storage duration and no-op constructor and destructor.
// This effectively makes tsan ignore destroy annotation.
static const unsigned __tsan_mutex_linker_init      = 1 << 0;
// Mutex is write reentrant.
static const unsigned __tsan_mutex_write_reentrant  = 1 << 1;
// Mutex is read reentrant.
static const unsigned __tsan_mutex_read_reentrant   = 1 << 2;
// Mutex does not have static storage duration, and must not be used after
// its destructor runs.  The opposite of __tsan_mutex_linker_init.
// If this flag is passed to __tsan_mutex_destroy, then the destruction
// is ignored unless this flag was previously set on the mutex.
static const unsigned __tsan_mutex_not_static       = 1 << 8;

These constants still are an issue:

static const unsigned __tsan_mutex_not_static = 1 << 8;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions