From patchwork Mon Jun 27 14:49:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Trofimovich X-Patchwork-Id: 55446 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6971138418B7 for ; Mon, 27 Jun 2022 14:50:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6971138418B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656341421; bh=p21GhnLu6LldiUCP4CanGsHKdU/JA0ZBtvoKzy9CN0I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=nhRW+llOqS7q2m9uox1BPn/Yt5VDzyVa06PNjFZtkGJ0p9sB+/Lc19gDEZ4tAR0yt rENswUtnHhFw69/pvUiuigtQPaQ97s4C/RYhEAZyOJ7kwIbx75ACHd7+EgLfISFMLD iy8uXDK3jPAtMw0Fle1jkDu4B6Ih6+fyi1iPKJq8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id BFBB23857B9C; Mon, 27 Jun 2022 14:49:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BFBB23857B9C Received: by mail-wm1-x32c.google.com with SMTP id bi22-20020a05600c3d9600b003a04de22ab6so874591wmb.1; Mon, 27 Jun 2022 07:49:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p21GhnLu6LldiUCP4CanGsHKdU/JA0ZBtvoKzy9CN0I=; b=Q5jGJB6Hb1LA4+BdgP2JIlVL/oVYix9VWMYac++gctTtOSx9Ep8SJxRb04hX0MjQBN ODMUR5UgFrOQpibNVHM8Iyfhqv97rvC4EGNSqM7haMJqb4v0VV/sh4jAgnslM5V60MeH juI68pIDQxI4F5ZzHPF4BjtFPWKh1VrQ5QRZJs/xdqMcFqmwp2LWOqmmJUaEV5eddIZx SDPhpVAC92w8ZuWrHbrQ5R+FLumo7BqpGOYHuRDbW7HIi/NU9SbCqhxezKXRmzwwICHp bKHEBhQ0AcCBIVVhFHr2ZUuY1niwokNoqm9N7O7O2gj1QOtPt8ZnX5sJo60RcqsQ13mY 7aAg== X-Gm-Message-State: AJIora/ggyG0XvT79wKBd2qTUCTHMb3/oaXSpg9cxBMI1RlaxXtTK6P9 ohVyFRvEIQWkCj425k0l2AWKlgjGKgU= X-Google-Smtp-Source: AGRyM1sGFxSBxP3Fo4Z0YVWzp67pPrJMMZDXkg39FwKfcED51JjqhnEtzVhsWCOeobqYuVy30xpv5Q== X-Received: by 2002:a05:600c:4f11:b0:39c:7410:de45 with SMTP id l17-20020a05600c4f1100b0039c7410de45mr15840479wmq.103.1656341389023; Mon, 27 Jun 2022 07:49:49 -0700 (PDT) Received: from nz.home (host81-147-8-3.range81-147.btcentralplus.com. [81.147.8.3]) by smtp.gmail.com with ESMTPSA id e6-20020a05600c218600b003a04b0bcb43sm3501450wme.40.2022.06.27.07.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 07:49:48 -0700 (PDT) Received: by nz.home (Postfix, from userid 1000) id B5F40574C7651; Mon, 27 Jun 2022 15:49:47 +0100 (BST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: avoid poisoning on musl [PR106102] Date: Mon, 27 Jun 2022 15:49:06 +0100 Message-Id: <20220627144906.470405-1-slyich@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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-Patchwork-Original-From: Sergei Trofimovich via Gcc-patches From: Sergei Trofimovich Reply-To: Sergei Trofimovich Cc: nathan@gcc.gnu.org, Sergei Trofimovich , rguenth@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Sergei Trofimovich On musl uses calloc() (via ). includes it indirectly and exposes use of poisoned calloc() when module code is built: /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35, .... from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77, from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24, from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25, from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23, from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32: /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" 84 | void *calloc(size_t, size_t); | ^ /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) | ^ gcc/cp/ * mapper-client.cc: Include via "system.h". * mapper-resolver.cc: Ditto. * module.cc: Ditto. libcc1/ * libcc1plugin.cc: Ditto. * libcp1plugin.cc: Ditto. --- gcc/cp/mapper-client.cc | 1 + gcc/cp/mapper-resolver.cc | 1 + gcc/cp/module.cc | 1 + libcc1/libcc1plugin.cc | 1 + libcc1/libcp1plugin.cc | 1 + 5 files changed, 5 insertions(+) diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc index 8603a886a09..fe9544b5ba4 100644 --- a/gcc/cp/mapper-client.cc +++ b/gcc/cp/mapper-client.cc @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #define INCLUDE_STRING #define INCLUDE_VECTOR #define INCLUDE_MAP +#define INCLUDE_MEMORY #include "system.h" #include "line-map.h" diff --git a/gcc/cp/mapper-resolver.cc b/gcc/cp/mapper-resolver.cc index e3d29fb5ada..e70d1b4ae2c 100644 --- a/gcc/cp/mapper-resolver.cc +++ b/gcc/cp/mapper-resolver.cc @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #define INCLUDE_VECTOR #define INCLUDE_ALGORITHM #define INCLUDE_MAP +#define INCLUDE_MEMORY #include "system.h" // We don't want or need to be aware of networking diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index e7ce40ef464..99f10733d4b 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -206,6 +206,7 @@ Classes used: #define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available. */ #include "config.h" +#define INCLUDE_MEMORY #define INCLUDE_STRING #define INCLUDE_VECTOR #include "system.h" diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc index 12ab5a57c8d..bdd0bdabe77 100644 --- a/libcc1/libcc1plugin.cc +++ b/libcc1/libcc1plugin.cc @@ -31,6 +31,7 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION +#define INCLUDE_MEMORY #include "gcc-plugin.h" #include "system.h" #include "coretypes.h" diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc index 83dab7f58b1..e2d5039a0a1 100644 --- a/libcc1/libcp1plugin.cc +++ b/libcc1/libcp1plugin.cc @@ -32,6 +32,7 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION +#define INCLUDE_MEMORY #include "gcc-plugin.h" #include "system.h" #include "coretypes.h"