Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect if ptrace not available and gracefully disable LeakSanitizer #916

Closed
ezyang opened this issue Feb 17, 2018 · 2 comments
Closed

Detect if ptrace not available and gracefully disable LeakSanitizer #916

ezyang opened this issue Feb 17, 2018 · 2 comments

Comments

@ezyang
Copy link

ezyang commented Feb 17, 2018

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.

@kcc
Copy link
Contributor

kcc commented Feb 17, 2018

if ptrace is disabled or you're working inside a Docker image.

yes

It would be much better if LeakSanitizer could detect if this is the trace, and turn itself off automatically (maybe with a warning.)

That's counter productive, imho

Or, if not that, mention this as another possible explanation.

This is somewhat reasonable. But such change won't affect users of older versions.
Mieanwhile, it is also very easy to find solutions in the internet.
For docker, the solution is to use --cap-add SYS_PTRACE

Or also suggest how to turn off LeakSanitizer manually with ASAN_OPTIONS.

This is part of the documentation.
https://clang.llvm.org/docs/AddressSanitizer.html#memory-leak-detection

@kcc kcc closed this as completed Feb 17, 2018
goaway pushed a commit to envoyproxy/envoy-mobile that referenced this issue Sep 2, 2021
Description: Due to google/sanitizers#916 we add an extra capability (SYS_PTRACE) to the remote execution docker container, we do this by adding a new Clang ASAN toolchain. Otherwise, dangling threads can fail the test during teardown (example with a previous run: https://github.com/envoyproxy/envoy-mobile/runs/3443649963). 

Risk Level: Low
Testing: See asan workflow
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Luis Fernando Pino Duque <luis@engflow.com>
malb added a commit to malb/m4ri that referenced this issue Sep 5, 2021
carloseltuerto pushed a commit to carloseltuerto/envoy-mobile that referenced this issue Sep 7, 2021
Description: Due to google/sanitizers#916 we add an extra capability (SYS_PTRACE) to the remote execution docker container, we do this by adding a new Clang ASAN toolchain. Otherwise, dangling threads can fail the test during teardown (example with a previous run: https://github.com/envoyproxy/envoy-mobile/runs/3443649963). 

Risk Level: Low
Testing: See asan workflow
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Luis Fernando Pino Duque <luis@engflow.com>
jpsim pushed a commit to envoyproxy/envoy that referenced this issue Nov 28, 2022
Description: Due to google/sanitizers#916 we add an extra capability (SYS_PTRACE) to the remote execution docker container, we do this by adding a new Clang ASAN toolchain. Otherwise, dangling threads can fail the test during teardown (example with a previous run: https://github.com/envoyproxy/envoy-mobile/runs/3443649963).

Risk Level: Low
Testing: See asan workflow
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Luis Fernando Pino Duque <luis@engflow.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit to envoyproxy/envoy that referenced this issue Nov 29, 2022
Description: Due to google/sanitizers#916 we add an extra capability (SYS_PTRACE) to the remote execution docker container, we do this by adding a new Clang ASAN toolchain. Otherwise, dangling threads can fail the test during teardown (example with a previous run: https://github.com/envoyproxy/envoy-mobile/runs/3443649963).

Risk Level: Low
Testing: See asan workflow
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Luis Fernando Pino Duque <luis@engflow.com>
Signed-off-by: JP Simard <jp@jpsim.com>
@arc4313
Copy link

arc4313 commented Jan 24, 2024

Can this be disabled in compile-time? For the case when we can't affect program env while perform tests.
Tried so far
-fsanitize=address -fno-sanitize=leak
and
ASAN_OPTIONS='detect_leaks=0' make
but still no success

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants