From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id F3309385AE55; Wed, 29 Jun 2022 06:54:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F3309385AE55 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 480E121E93; Wed, 29 Jun 2022 06:54:45 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3173E132C0; Wed, 29 Jun 2022 06:54:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id r2ACDDX3u2KKQwAAMHmgww (envelope-from ); Wed, 29 Jun 2022 06:54:45 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2] jit: avoid calloc() poisoning on musl [PR106102] Date: Wed, 29 Jun 2022 08:54:44 +0200 Message-Id: References: <20220628210529.2013070-1-slyich@gmail.com> Cc: gcc-patches@gcc.gnu.org, rguenth@gcc.gnu.org, dmalcolm@redhat.com, Sergei Trofimovich In-Reply-To: <20220628210529.2013070-1-slyich@gmail.com> To: Sergei Trofimovich X-Mailer: iPhone Mail (19F77) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 06:54:48 -0000 > Am 28.06.2022 um 23:06 schrieb Sergei Trofimovich : >=20 > =EF=BB=BFFrom: Sergei Trofimovich >=20 > On musl uses calloc() (via ). jit/ includes > it directly and exposes use of poisoned calloc(): >=20 > /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/jit/jit-play= back.cc > make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1 > make[3]: *** Waiting for unfinished jobs.... > In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, > from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44:= > /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poi= soned "calloc" > 84 | void *calloc(size_t, size_t); > | ^ > /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use p= oisoned "calloc" > 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))= > | ^ >=20 > The change moves inclusion to "system.h" under new > INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit. Ok, Thanks, Richard=20 > gcc/ >=20 > PR c++/106102 > * system.h: Introduce INCLUDE_PTHREAD_H macros to include . >=20 > gcc/jit/ >=20 > PR c++/106102 > * jit-playback.cc: Include via "system.h" to avoid calloc()= > poisoning. > * jit-recording.cc: Ditto. > * libgccjit.cc: Ditto. > --- > gcc/jit/jit-playback.cc | 3 +-- > gcc/jit/jit-recording.cc | 2 +- > gcc/jit/libgccjit.cc | 2 +- > gcc/system.h | 4 ++++ > 4 files changed, 7 insertions(+), 4 deletions(-) >=20 > diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc > index 6be6bdf8dea..79714132b91 100644 > --- a/gcc/jit/jit-playback.cc > +++ b/gcc/jit/jit-playback.cc > @@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see > . */ >=20 > #include "config.h" > +#define INCLUDE_PTHREAD_H > #include "system.h" > #include "coretypes.h" > #include "target.h" > @@ -41,8 +42,6 @@ along with GCC; see the file COPYING3. If not see > #include "diagnostic.h" > #include "stmt.h" >=20 > -#include > - > #include "jit-playback.h" > #include "jit-result.h" > #include "jit-builtins.h" > diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc > index 697dee66e73..f78daed2d71 100644 > --- a/gcc/jit/jit-recording.cc > +++ b/gcc/jit/jit-recording.cc > @@ -19,13 +19,13 @@ along with GCC; see the file COPYING3. If not see > . */ >=20 > #include "config.h" > +#define INCLUDE_PTHREAD_H > #include "system.h" > #include "coretypes.h" > #include "tm.h" > #include "pretty-print.h" > #include "toplev.h" >=20 > -#include >=20 > #include "jit-builtins.h" > #include "jit-recording.h" > diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc > index 0e76097b4ba..ca862662777 100644 > --- a/gcc/jit/libgccjit.cc > +++ b/gcc/jit/libgccjit.cc > @@ -19,12 +19,12 @@ along with GCC; see the file COPYING3. If not see > . */ >=20 > #include "config.h" > +#define INCLUDE_PTHREAD_H > #include "system.h" > #include "coretypes.h" > #include "timevar.h" > #include "typed-splay-tree.h" > #include "cppbuiltin.h" > -#include >=20 > #include "libgccjit.h" > #include "jit-recording.h" > diff --git a/gcc/system.h b/gcc/system.h > index 67158b70c78..f8d42ff6815 100644 > --- a/gcc/system.h > +++ b/gcc/system.h > @@ -753,6 +753,10 @@ extern int vsnprintf (char *, size_t, const char *, v= a_list); > #endif > #endif >=20 > +#ifdef INCLUDE_PTHREAD_H > +#include > +#endif > + > #ifdef INCLUDE_ISL > #ifdef HAVE_isl > #include > --=20 > 2.36.1 >=20