Skip to content

Detect if ptrace not available and gracefully disable LeakSanitizer #916

@ezyang

Description

@ezyang

If I understand correctly, the following situation:

jenkins@ff742997f986:~$ echo "int main() { return 0; }" > test.c
jenkins@ff742997f986:~$ clang-5.0 -fsanitize=address test.c
jenkins@ff742997f986:~$ ./a.out 
==4821==LeakSanitizer has encountered a fatal error.
==4821==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==4821==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)

occurs whenever you don't have ptrace rights, e.g., if ptrace is disabled or you're working inside a Docker image. It would be much better if LeakSanitizer could detect if this is the trace, and turn itself off automatically (maybe with a warning.) Or, if not that, mention this as another possible explanation. Or also suggest how to turn off LeakSanitizer manually with ASAN_OPTIONS.

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