Skip to content

asan + rr + libGLX __glDispatchInit prevent applications from starting #2746

@milianw

Description

@milianw

To reproduce:

$ cat test.cpp
int main() { return 0; }
$ g++ -g -O0 -l GLX -fsanitize=address,undefined test.cpp
ldd a.out
        linux-vdso.so.1 (0x00007ffc9d5d7000)
        libasan.so.6 => /usr/lib/libasan.so.6 (0x00007f8da32df000)
        libGLX.so.0 => /usr/lib/libGLX.so.0 (0x00007f8da32ac000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f8da30cf000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007f8da2f89000)
        libubsan.so.1 => /usr/lib/libubsan.so.1 (0x00007f8da261b000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f8da2601000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f8da2436000)
        libdl.so.2 => /usr/lib/../lib/libdl.so.2 (0x00007f8da2430000)
        librt.so.1 => /usr/lib/../lib/librt.so.1 (0x00007f8da2425000)
        libpthread.so.0 => /usr/lib/../lib/libpthread.so.0 (0x00007f8da2403000)
        libGLdispatch.so.0 => /usr/lib/libGLdispatch.so.0 (0x00007f8da234c000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f8da220b000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f8da3cfa000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f8da21df000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f8da21da000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f8da21d2000)
$ ./a.out
# works fine
$ rr record ./a.out
# never finishes

according to perf, this is what happens:
rr-asan-mutexlock

I guess there's something fishy going on with asan and rr both trying to intercept pthread_mutex_lock here. Oddly enough, a simpler application with a normal mutex seems to work. So I guess it's also important that the mutex is locked from a global static that's called from dl_init in a library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions