[PATCH] D74154: LSAN for android

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 12:52:33 PST 2020


eugenis added inline comments.


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:485
+                                   reinterpret_cast<void**>(&end_addr))){
+    fprintf(stderr, "Error getting TLS bounds\n");
+    *addr = 0;
----------------
oontvoo wrote:
> eugenis wrote:
> > oontvoo wrote:
> > > eugenis wrote:
> > > > Printf
> > > If the sanitizer crashes (which it does sometimes, mostly due to bugs) stuff going into printf() will not get printed - which makes it hard to debug.
> > This code needs to be async signal safe, which fprintf is not. What kinds of bugs do you have in mind? Printf goes almost directly to stderr.
> Ah, ok. I've switched the code to use write(), which should be signal safe. (http://man7.org/linux/man-pages/man7/signal.7.html)
> 
> When iterating on this patch, I had a few thinkos, causing sigsev and the log messages sent to printf were buffered and never got printed (I think they went to stdout, not stderr).
> That's why I wanted to use stderr, which is not buffered.
write can be intercepted, when running as part of asan for instance.
Printf goes to stderr, see "log_path" in sanitizer_flags.inc.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74154/new/

https://reviews.llvm.org/D74154





More information about the llvm-commits mailing list