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

LeakSanitizer leads to the program exiting with an error code with no output when leaks are present #3589

Closed
zeux opened this issue Oct 3, 2018 · 8 comments

Comments

@zeux
Copy link

zeux commented Oct 3, 2018

In Windows October 2018 update (1809, build 17763.1) leak sanitizer no longer produces a visible error in the output (#3053). However, if the program has any leaks, the program exits with code 1 but doesn't produce any output.

I suspect that in a successful execution (with no leaks), leak sanitizer still fails to run correctly, but the output is suppressed. I may be wrong since it's hard to analyze the behavior considering that leak sanitizer doesn't guarantee that it works under strace.

STR:
Compile the following code with clang++ -fsanitize=address and run:

int main()
{
    new int;
}

Running the program produces no output, but the exit code is 1. strace gives the following result:

prctl(PR_SET_PTRACER, 467)              = 0
futex(0x7ffff8e66960, FUTEX_WAKE, 1)    = 1
wait4(467, NULL, __WALL, NULL)          = -1 ECHILD (No child processes)
munmap(0x7fc5323f0000, 2101248)         = 0
getpid()                                = 466
write(2, "==466==LeakSanitizer has encountered a fatal error.\n", 52) = -1 EBADF (Bad file descriptor)
write(2, "ReportFile::Write() can't output requested buffer!\n", 51) = -1 EBADF (Bad file descriptor)
exit_group(1)                           = ?
+++ exited with 1 +++

I suspect that the root cause is that wait4 on the pid that was set as ptracer fails.

@stoperro
Copy link

Same issue here. On PC with older WSL I have same issue as in #121 (which is still not fixed, but dirty workaround with ptrace_scope helps).

@tara-raj
Copy link

tara-raj commented Oct 23, 2018

Could you please provide the earlier part of the trace so we can get more info on this? Thanks in advance!

@zeux
Copy link
Author

zeux commented Oct 23, 2018

FWIW I tried reproducing this on my work PC that has Windows 1803 (build 17134.345) and I couldn't reproduce it - leak sanitizer worked correctly. However, this was on Ubuntu Xenial (16.04). I think the system I reported the bug from originally may have been using Bionic (18.04). I'll update this bug with more precise version information and full strace dump.

@therealkenc
Copy link
Collaborator

therealkenc commented Oct 23, 2018

$ sudo apt install clang
$ echo "int main() { new int; }" > foo.cpp
$ clang++ -fsanitize=address foo.cpp
$ ./a.out
$ echo $?
1
$ strace -f -o aout.strace ./aout

[But you already know that.] strace output. Also strace of same repro on Real Linux here 'cause whynot.

Since I'm here (and only since)...

I have same issue as in #121

You do not. Or rather, if you are still seeing AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0) in the 1809 Win10 build with an empty test.c, please feel encouraged to open a new issue following CONTRIBUTING.md. This is a rhetorical suggestion, mind. Because #121 is fixed [it's actually dupe #708 (message)]. So is #3053. This issue is, as of this writing, not.

@stoperro
Copy link

True, I've oversimplified. I didn't mean problem with "CHECK failed", but the fact that "ASAN doesn't work" that can be worked-around with setting ptrace_scope=0 as zeux pointed. I understand there are/were various reasons for broken ASAN there.

@zeux
Copy link
Author

zeux commented Oct 24, 2018

Here's the full strace dump:
a.log

You can also generate it yourself as @therealkenc suggested above. The bug happens in the following setup:

Windows 10 version 1809 (OS Build 17763.55)
Ubuntu 18.04 installed from Microsoft Store

uname -a:
Linux zeux-minisurface 4.4.0-17763-Microsoft #55-Microsoft Sat Oct 06 18:05:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a:
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

@Brian-Perkins
Copy link

This should be resolved as of Build 18305.

@therealkenc
Copy link
Collaborator

This shipped in 1903.

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

5 participants