Skip to content

__sanitizer::StopTheWorld sometimes hangs #777

@evverx

Description

@evverx

How to reproduce:

$ rpm -q clang compiler-rt libseccomp
clang-3.8.1-1.fc25.x86_64
compiler-rt-3.8.1-1.fc25.x86_64
libseccomp-2.3.1-1.fc25.x86_64

$ cat /proc/version
Linux version 4.9.10-200.fc25.x86_64 ([email protected]) (gcc version 6.3.1 20161221 (Red Hat 6.3.1-1) (GCC) ) #1 SMP Wed Feb 15 23:28:59 UTC 2017

$ grep SECCOMP /boot/config-4.9.10-200.fc25.x86_64
CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
CONFIG_SECCOMP_FILTER=y
CONFIG_SECCOMP=y
#include <seccomp.h>

int main(int argc, char *argv[]) {
        scmp_filter_ctx ctx;
        int r = -1;

        ctx = seccomp_init(SCMP_ACT_ALLOW);
        if (!ctx)
                goto out;

        r = seccomp_rule_add(ctx, SCMP_ACT_KILL, SCMP_SYS(ptrace), 0);
        if (r < 0)
                goto out;

        r = seccomp_load(ctx);
        if (r < 0)
                goto out;

out:
        seccomp_release(ctx);
        return -r;
}
$ clang -o hang-stop-the-world -fsanitize=address -lseccomp ./hang-stop-the-world.c

$ ./hang-stop-the-world &
[1] 30768

$ ps -C hang-stop-the-world
  PID TTY          TIME CMD
30768 pts/2    00:00:16 hang-stop-the-w
30769 pts/2    00:00:00 hang-stop-the-w <defunct>

$ sudo journalctl -b _TRANSPORT=audit -o cat | grep -i hang-stop
SECCOMP auid=1001 uid=1001 gid=1001 ses=4 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 pid=30769 comm="hang-stop-the-w" exe="/home/vagrant/hang-stop-the-world" sig=31 arch=c000003e syscall=101 compat=0 ip=0x4cef73 code=0x0

$ pidstat 1 5
...
Average:      UID       PID    %usr %system  %guest    %CPU   CPU  Command
...
Average:     1001     30768    8.88   82.45    0.00   91.32     -  hang-stop-the-w

$ pstack 30768
#0  0x00007fec211ba2c7 in sched_yield () at ../sysdeps/unix/syscall-template.S:84
#1  0x00000000004dd105 in __sanitizer::StopTheWorld(void (*)(__sanitizer::SuspendedThreadsList const&, void*), void*) ()
#2  0x00000000004e28f0 in __lsan::DoStopTheWorldCallback(dl_phdr_info*, unsigned long, void*) ()
#3  0x00007fec21213ab4 in __GI___dl_iterate_phdr (callback=0x4e28e0 <__lsan::DoStopTheWorldCallback(dl_phdr_info*, unsigned long, void*)>, data=0x7ffe27214670) at dl-iteratephdr.c:76
#4  0x00000000004e2c8c in __lsan::DoStopTheWorld(void (*)(__sanitizer::SuspendedThreadsList const&, void*), void*) ()
#5  0x00000000004e1e5b in __lsan::CheckForLeaks() [clone .part.27] ()
#6  0x00000000004e2158 in __lsan::DoLeakCheck() ()
#7  0x00007fec21109410 in __run_exit_handlers (status=0, listp=0x7fec2148f5b8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:83
#8  0x00007fec2110946a in __GI_exit (status=<optimized out>) at exit.c:105
#9  0x00007fec210ef408 in __libc_start_main (main=0x4e7be0 <main>, argc=1, argv=0x7ffe27214848, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe27214838) at ../csu/libc-start.c:323
#10 0x000000000041870a in _start ()

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