[PATCH] D64057: Add NetBSD LSan support

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 01:20:15 PDT 2019


krytarowski added a comment.

In D64057#1579974 <https://reviews.llvm.org/D64057#1579974>, @lebedev.ri wrote:

> In D64057#1579961 <https://reviews.llvm.org/D64057#1579961>, @krytarowski wrote:
>
> > I've landed this version as it is good enough to land LLVM-9.
> >
> > Unfortunately many tests fail as they seem to be tuned for Linux/Darwin.
> >
> > Please see:
> >
> > https://reviews.llvm.org/D64057#1565937
> >
> > @vitalybuka how to address these problems?
>
>
> Can you show how the tests *fail*>
>  I.e. what is the diff between expected and actual output?


For start most of the problems come from this:

1. LSan registers check in AtExit(). There are other callbacks registered out there.
2. In __cxa_finalize() we first call the callbacks and at the end of the procedure we free() the memory

https://nxr.netbsd.org/xref/src/lib/libc/stdlib/atexit.c#191

  247 
  248 	/*
  249 	 * Now free any dead handlers.  Do this even if we're about to
  250 	 * exit, in case a leak-detecting malloc is being used.
  251 	 */
  252 	while ((ah = dead_handlers) != NULL) {
  253 		dead_handlers = ah->ah_next;
  254 		free(ah);
  255 	}
  256 }



3. In the tests there is enforced option `use_stacks=0`. This leads to false positives that `struct atexit_handler *ah;` is leaked. This is not true as its reference is still kept and it will be released soon after finishing execution of the callbacks.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64057





More information about the llvm-commits mailing list