Live data from Hacker News

OpenBSD: Malloc leak detection available in -current

undeadly.org

1–10 of 61 posts

Re: OpenBSD: Malloc leak detection available in -current

#5

Why duplicate the efforts of valgrind and address sanitizer?

Both of those are very useful, but slow, especially valgrind.

I don't know OpenBSD, but presumably this is analogous to glibc's relatively faster memory sanity checking.

For GCC and clang you'd also want LSAN for this, not ASAN. ASAN is more accurate for edge cases, but much slower.

"Slow" here means that even for development the runtime can be prohibitively expensive.

E.g. I regularly run git's test suite, optimized/LSAN/ASAN/valgrind runtime is on the order of 3m/15m/30m/24 hours. The basic glibc sanity checking only adds a minute or two to the optimized run.

An advantage of any malloc based detection is also that you can run it on any existing binary. Whereas the likes of LSAN and ASAN require a custom debugging build (or to have that tracing overhead present in your production build).

Re: OpenBSD: Malloc leak detection available in -current

#6

Why duplicate the efforts of valgrind and address sanitizer?

In addition to what others said, Valgrind is GPL-licensed. That conflicts with the OpenBSD copyright policy (https://www.openbsd.org/policy.html), which says:

“The GNU Public License and licenses modeled on it impose the restriction that source code must be distributed or made available for all works that are derivatives of the GNU copyrighted code.

While this may superficially look like a noble strategy, it is a condition that is typically unacceptable for commercial use of software. So in practice, it usually ends up hindering free sharing and reuse of code and ideas rather than encouraging it. As a consequence, no additional software bound by the GPL terms will be considered for inclusion into the OpenBSD base system.”

As to clang’s Address Sanitizer, that’s under the Apache License v2.0 with LLVM Exceptions (https://github.com/google/sanitizers/blob/master/LICENSE.TXT), of which the same page says:

“The original Apache license was similar to the Berkeley license, but source code published under version 2 of the Apache license is subject to additional restrictions and cannot be included into OpenBSD. In particular, if you use code under the Apache 2 license, some of your rights will terminate if you claim in court that the code violates a patent.”

Re: OpenBSD: Malloc leak detection available in -current

#7
This is great news to me, it is the one think I was hoping for.

I use OpenBSD to test objects I create and testing there discovered issues that Linux and AIX happily ignored. But I used valgrind on Linux to look for leaks. With this I can now test for all "my issues" on OpenBSD :)

Re: OpenBSD: Malloc leak detection available in -current

#8
post #6

Why duplicate the efforts of valgrind and address sanitizer?

In addition to what others said, Valgrind is GPL-licensed. That conflicts with the OpenBSD copyright policy ( https://www.openbsd.org/policy.html ), which says: “The GNU Public License and licenses modeled on it impose the restriction that source code must be distributed or made available for all works that are derivatives of the GNU copyrighted code. While this may superficially look like a noble strategy, it is a c…

True, but I think having this check in the kernel may work better than valgrind on Linux.

With that said, valgrind works great and I like its output, time will tell if I will like the output from this OpenBSD change.

Re: OpenBSD: Malloc leak detection available in -current

#9
post #6

Why duplicate the efforts of valgrind and address sanitizer?

In addition to what others said, Valgrind is GPL-licensed. That conflicts with the OpenBSD copyright policy ( https://www.openbsd.org/policy.html ), which says: “The GNU Public License and licenses modeled on it impose the restriction that source code must be distributed or made available for all works that are derivatives of the GNU copyrighted code. While this may superficially look like a noble strategy, it is a c…

I had no idea that OpenBSD didn't accept Apache 2 code

https://www.openbsd.org/policy.html

Re: OpenBSD: Malloc leak detection available in -current

#10
To quota GNU libc manual:

> There is no point in freeing blocks at the end of a program, because all of the program’s space is given back to the system when the process terminates.

https://www.gnu.org/software/libc/manual/html_node/Freeing-a...

I think many GNU tools just never free any memory.

For example, GCC : https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66339

-- edit: added GCC as example.

Post reply on HN