Issue 57288
Summary [compiler-rt] TSAN Dynamic Library Linker Error on Ubuntu
Labels new issue
Assignees
Reporter lstricevic
    When compiling this piece of code with dynamically linked ThreadSanitizer runtime library, linking error occurs:
```
#include <stdio.h>
#include <pthread.h>

int x=0;

void* fun(void* in) {
    for (int i = 0; i < 10000000; i++ ) 
        x++;
    return NULL;
}

int main(){
    pthread_t t1, t2;
    pthread_create(&t1, NULL, fun, NULL);
    pthread_create(&t2, NULL, fun, NULL);
    pthread_join(t1, NULL);
    pthread_join(t2, NULL);

    printf("X: %d\n", x);
    return 0;
}
```
Compiling with:

`clang -fsanitize=thread -shared-libsan -lpthread race.c`

gives linker error:
```
/usr/bin/ld: /opt/src/llvm-project/build-2108/lib/clang/16.0.0/lib/x86_64-unknown-linux-gnu/libclang_rt.tsan.so: siglongjmp: invalid version 21 (max 0)
/opt/src/llvm-project/build-2108/lib/clang/16.0.0/lib/x86_64-unknown-linux-gnu/libclang_rt.tsan.so: error adding symbols: Bad value
```
Affected versions of LLVM are 14.x, 15.x and current (commit d9756fa723be). Error can be also reproduced with binary release: https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz

The tests have been made on x86_64 Ubuntu 18.04 and 20.04 versions.


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to