From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [RFC PATCH] Allow annotating calloc for Valgrind
Date: Thu, 29 Jun 2017 19:20:32 -0400 [thread overview]
Message-ID: <20170629232032.GH1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <20170629225614.19061-1-amonakov@ispras.ru>
On Fri, Jun 30, 2017 at 01:56:14AM +0300, Alexander Monakov wrote:
> With mal0_clear entered only for larger-than-one-page allocations, a
> few additional nops and stack accesses don't matter.
>
> This only needs Valgrind headers to build, Valgrind itself doesn't need to be
> built/installed. However, valgrind.h unconditionally includes stdarg.h.
Use of valgrind annotation was already rejected a long time ago. The
same can be done with a suppressions file and that's where it belongs.
> Untested.
> ---
> configure | 11 +++++++++++
> src/malloc/malloc.c | 4 ++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/configure b/configure
> index c2db298c..7e78094f 100755
> --- a/configure
> +++ b/configure
> @@ -30,6 +30,7 @@ System types:
> Optional features:
> --enable-optimize=... optimize listed components for speed over size [auto]
> --enable-debug build with debugging information [disabled]
> + --enable-valgrind add Valgrind annotations [disabled]
> --enable-warnings build with recommended warnings flags [disabled]
> --enable-visibility use global visibility options to optimize PIC [auto]
> --enable-wrapper=... build given musl toolchain wrapper [auto]
> @@ -134,6 +135,7 @@ build=
> target=
> optimize=auto
> debug=no
> +valgrind=no
> warnings=no
> visibility=auto
> shared=auto
> @@ -161,6 +163,8 @@ case "$arg" in
> --disable-optimize) optimize=no ;;
> --enable-debug|--enable-debug=yes) debug=yes ;;
> --disable-debug|--enable-debug=no) debug=no ;;
> +--enable-valgrind|--enable-valgrind=yes) valgrind=yes ;;
> +--disable-valgrind|--enable-valgrind=no) valgrind=no ;;
> --enable-warnings|--enable-warnings=yes) warnings=yes ;;
> --disable-warnings|--enable-warnings=no) warnings=no ;;
> --enable-visibility|--enable-visibility=yes) visibility=yes ;;
> @@ -390,6 +394,13 @@ tryflag CFLAGS_MEMOPS -fno-tree-loop-distribute-patterns
> #
> test "$debug" = yes && CFLAGS_AUTO=-g
>
> +if test x"$valgrind" = xyes ; then
> +CPPFLAGS="$CPPFLAGS -DVG_MEMCHECK_H='<memcheck.h>'"
> +else
> +CPPFLAGS="$CPPFLAGS -DVG_MEMCHECK_H='</dev/null>'"
> +fi
> +CPPFLAGS="${CPPFLAGS# }"
> +
> #
> # Preprocess asm files to add extra debugging information if debug is
> # enabled, our assembler supports the needed directives, and the
> diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c
> index b56fdaa2..d4c229bd 100644
> --- a/src/malloc/malloc.c
> +++ b/src/malloc/malloc.c
> @@ -8,6 +8,7 @@
> #include "libc.h"
> #include "atomic.h"
> #include "pthread_impl.h"
> +#include VG_MEMCHECK_H
This looks really flaky, and makes compilation dependent on a
POSIX-conforming filesystem. For example it almost certainly breaks
cross-compiling from a mingw-based cross compiler (which
musl-cross-make supports building).
The same could be achieved without hacks just using #if/#ifdef around
the #include. But I don't see how <memcheck.h> could work anyway; musl
obviously does not, and can't, use any host include paths where a
header might already be installed.
Rich
next prev parent reply other threads:[~2017-06-29 23:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-29 22:56 Alexander Monakov
2017-06-29 23:20 ` Rich Felker [this message]
2017-06-29 23:42 ` Alexander Monakov
2017-06-29 23:56 ` Rich Felker
2017-07-02 13:55 ` Alexander Monakov
2017-07-02 14:35 ` Rich Felker
2017-07-02 16:16 ` Alexander Monakov
2017-07-02 16:31 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170629232032.GH1627@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).