Skip to content

[TSan] Segfault with target_clones attribute #163369

@kleisauke

Description

@kleisauke

reduced.c

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

int main(void) {
    int (*func)(void) = has_target_clones;
    return func();
}

(i.e. using the same reproducer as mentioned in #70184 (comment))

$ clang -O0 -g -fsanitize=thread reduced.c
$ ./a.out
Segmentation fault (core dumped)
$ coredumpctl debug
...
Core was generated by `./a.out'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __sanitizer::atomic_load<__sanitizer::atomic_uintptr_t> (a=0x18, mo=__sanitizer::memory_order_relaxed)
    at /home/kleisauke/llvm-project/compiler-rt/lib/tsan/rtl/../../sanitizer_common/sanitizer_atomic_clang.h:56
56	  return __atomic_load_n(&a->val_dont_use, mo);

Tested with the latest revision (commit 0ebcc97 at the time of writing):

$ clang --version
clang version 22.0.0git (https://github.com/llvm/llvm-project.git 0ebcc97e1148b5a3863ebf8c669a71450fe3a531)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/kleisauke/llvm-project/build/bin
Build config: +assertions

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