Issue 150380
Summary Hang in __sanitizer::StopTheWorld when ptrace system call is disallowed
Labels new issue
Assignees
Reporter correctmost
    ### Description

This hang was initially described in https://github.com/google/sanitizers/issues/777.  I see the hang locally with a systemd service that has a `SystemCallFilter` setting that blocks `ptrace`.

### Steps to reproduce

The steps to reproduce from https://github.com/google/sanitizers/issues/777 still work:

1 - Save `hang-stop-the-world.c`

```c
#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;
}
```

2 - Run `clang -o hang-stop-the-world -ggdb3 -fsanitize=address -lseccomp ./hang-stop-the-world.c`
3 - Run `./hang-stop-the-world`

### Backtrace
```
0x00007ffff7d5d98b in __GI_sched_yield () at ../sysdeps/unix/syscall-template.S:120
120	T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) bt
#0  0x00007ffff7d5d98b in __GI_sched_yield () at ../sysdeps/unix/syscall-template.S:120
#1 0x00005555556b1386 in __sanitizer::StopTheWorld(void (*)(__sanitizer::SuspendedThreadsList const&, void*), void*) ()
#2 0x00005555556c8ca1 in __lsan::LockStuffAndStopTheWorldCallback(dl_phdr_info*, unsigned long, void*) ()
#3  0x00007ffff7dc5287 in __GI___dl_iterate_phdr (callback=0x5555556c8c80 <__lsan::LockStuffAndStopTheWorldCallback(dl_phdr_info*, unsigned long, void*)>, data=""
    at dl-iteratephdr.c:74
#4 0x00005555556c9001 in __lsan::LockStuffAndStopTheWorld(void (*)(__sanitizer::SuspendedThreadsList const&, void*), __lsan::CheckForLeaksParam*) ()
#5  0x00005555556c5630 in __lsan::CheckForLeaksOnce() ()
#6  0x00005555556c5945 in __lsan::DoLeakCheck() ()
#7  0x00007ffff7c9d060 in __cxa_finalize (d=0x55555570d028) at cxa_finalize.c:97
#8  0x0000555555580178 in ?? ()
#9 0x00007fffffffe180 in ?? ()
#10 0x00007ffff7fc7fd2 in _dl_call_fini (closure_map=0x7ffff7ffe310) at dl-call_fini.c:43
```

### Expected behavior
An error is emitted with a note about missing ptrace capabilities (to make the issue easier to debug)

### Version info
clang 20.1.8-1 on Arch Linux
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to