From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11630 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [RFC PATCH] Allow annotating calloc for Valgrind Date: Thu, 29 Jun 2017 19:20:32 -0400 Message-ID: <20170629232032.GH1627@brightrain.aerifal.cx> References: <20170629225614.19061-1-amonakov@ispras.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1498778451 28073 195.159.176.226 (29 Jun 2017 23:20:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 29 Jun 2017 23:20:51 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11643-gllmg-musl=m.gmane.org@lists.openwall.com Fri Jun 30 01:20:47 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dQiju-00070W-JS for gllmg-musl@m.gmane.org; Fri, 30 Jun 2017 01:20:46 +0200 Original-Received: (qmail 26044 invoked by uid 550); 29 Jun 2017 23:20:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 26012 invoked from network); 29 Jun 2017 23:20:44 -0000 Content-Disposition: inline In-Reply-To: <20170629225614.19061-1-amonakov@ispras.ru> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11630 Archived-At: 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=''" > +else > +CPPFLAGS="$CPPFLAGS -DVG_MEMCHECK_H=''" > +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 could work anyway; musl obviously does not, and can't, use any host include paths where a header might already be installed. Rich