https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122894

            Bug ID: 122894
           Summary: ThreadSanitizer: segfault with target_clones attribute
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: info at kleisauke dot nl
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

`reduced.c`
```
__attribute__((target_clones("avx,default")))
static int has_target_clones(void) {
  return 0;
}

int main(void) { has_target_clones(); }
```

```
$ gcc -O0 -g -fsanitize=thread reduced.c
$ ./a.out
Segmentation fault (core dumped)
$ coredumpctl debug
...
Program terminated with signal SIGSEGV, Segmentation fault.
Downloading source file
/usr/src/debug/gcc-15.2.1-4.fc43.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libsanitizer/tsan/../../../../libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
#0  __sanitizer::atomic_load<__sanitizer::atomic_uintptr_t> (a=0x18,
mo=__sanitizer::memory_order_relaxed) at
../../../../libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:39           
39      inline typename T::Type atomic_load(const volatile T *a, memory_order
mo) {
$ gcc --version
gcc (GCC) 15.2.1 20251111 (Red Hat 15.2.1-4)
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

This was fixed in Clang via PR
https://github.com/llvm/llvm-project/pull/167516.

Reply via email to