Message ID | 20211105211718.2261686-1-rep.dot.nop@gmail.com |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> 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 12FBF385841A for <patchwork@sourceware.org>; Fri, 5 Nov 2021 21:21:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12FBF385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636147262; bh=56+sLolvkzzF1/jztz4nWY+g9O7ysUeFlbj8T14UuEI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=IBRcF1zkHnovMvLtf+ApUxqSJnFhx2kaqBiO44DW0ibGvf7v/QmjFNpVaojhjIiAT 8FK2WRtC4FzJvo/NfKzgfVc9K68fPhNeEaV4gNsEV7Rf43wo40tt3zHUJ//XusHzXS wv48HePeq5shwrsBVFU/A58bjHPc1Y9u+oQY9r/E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 8A396385841A; Fri, 5 Nov 2021 21:17:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8A396385841A Received: by mail-wr1-x436.google.com with SMTP id c4so15727534wrd.9; Fri, 05 Nov 2021 14:17:41 -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=56+sLolvkzzF1/jztz4nWY+g9O7ysUeFlbj8T14UuEI=; b=hiM6UtVwOo6SPxPBVYRDTEpqyFOmLc15uGE4Prc7qsinCUslM+vsgulcCU73c10fns yl5CygPZRKTc32IQOOYD/U8cgMfQ6J/xjOYJS+AFEojNCos1gaEeg+r6wTJ7aKnzHBLR I47w0092j89A5uuPs5DCYTW9xAWxZKxOdjRd1SMZlnq6t1wEDgW7pY/gVqs3jQ3gzuyh PAcslHL8BrVYKmawYOLGiCUkCH/3ITbxrSFKJ1fPIYbzsa6DVrfzgW1yTm+1rF+Cl1QI oG1Z7kF5ZVAx27lcGXYlHQhVWLCVvGiAbYvnGzJV6uKZ/ByS22aOCqHVE+6o4W+XYoMs ssDg== X-Gm-Message-State: AOAM532UQkKmCgNCk1wCOQOt3Kg5uO4aPlJBJOCSiLDYrQ/xRN0Zw3dc PFvIP7FYRZSAUhgfHO44TMgzR9g5nSs= X-Google-Smtp-Source: ABdhPJxnH0vOnYtHYVB+E5w1TP8nZj7ok/e+Pxe/EV9AsnGpoYRatjdqwOcKtXmHVRdmf+0qS71WRw== X-Received: by 2002:a5d:6e8c:: with SMTP id k12mr75364846wrz.401.1636147060244; Fri, 05 Nov 2021 14:17:40 -0700 (PDT) Received: from nbbrfq.weghof (dynamic-2bq7di4u2lfl4qjka9-pd01.res.v6.highway.a1.net. [2001:871:227:33a8:f6a3:c58c:7641:e771]) by smtp.gmail.com with ESMTPSA id g4sm8778705wro.12.2021.11.05.14.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Nov 2021 14:17:38 -0700 (PDT) Received: from b by nbbrfq.weghof with local (Exim 4.95) (envelope-from <b@localhost>) id 1mj6af-009UNA-Jf; Fri, 05 Nov 2021 22:17:37 +0100 To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH 0/2] incpath, Fortran: Fix memory leak in gfc_add_include_path Date: Fri, 5 Nov 2021 22:17:16 +0100 Message-Id: <20211105211718.2261686-1-rep.dot.nop@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Bernhard Reutner-Fischer via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
incpath, Fortran: Fix memory leak in gfc_add_include_path
|
|
Message
Bernhard Reutner-Fischer
Nov. 5, 2021, 9:17 p.m. UTC
Hi! In order to fix this very minor leak, we need a knob to free all cpp_dirs that were added. This adds a free_cpp_dirs() to gcc/incpath and needs review from some global maintainer or maybe libcpp maintainer for this hunk. Bootstrapped and regtested on x86_64-unknown-linux without regressions. Ok for tunk? Bernhard Reutner-Fischer (2): Add free_cpp_dirs() Fortran: Fix memory leak in gfc_add_include_path [PR68800] gcc/fortran/cpp.c | 13 +++++++++++-- gcc/fortran/cpp.h | 1 + gcc/fortran/f95-lang.c | 2 +- gcc/fortran/scanner.c | 7 ++++--- gcc/incpath.c | 13 +++++++++++++ gcc/incpath.h | 1 + 6 files changed, 31 insertions(+), 6 deletions(-)
Comments
On Fri, 5 Nov 2021 22:17:16 +0100 Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote: > Hi! > > In order to fix this very minor leak, we need a knob to free all > cpp_dirs that were added. > This adds a free_cpp_dirs() to gcc/incpath and needs review from some > global maintainer or maybe libcpp maintainer for this hunk. One thing that i want to note is that it sounds a tiny bit odd that we (the fortran FE) pull in the usual C paths, but maybe that's deliberate and agreed on? We have in incpath.c: > /* Exported function to handle include chain merging, duplicate > removal, and registration with cpplib. */ > void > register_include_chains (cpp_reader *pfile, const char *sysroot, > const char *iprefix, const char *imultilib, > int stdinc, int cxx_stdinc, int verbose) > { > static const char *const lang_env_vars[] = > { "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH", > "OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" }; > cpp_options *cpp_opts = cpp_get_options (pfile); > size_t idx = (cpp_opts->objc ? 2: 0); > > if (cpp_opts->cplusplus) > idx++; > else > cxx_stdinc = false; > > /* CPATH and language-dependent environment variables may add to the > include chain. */ > add_env_var_paths ("CPATH", INC_BRACKET); > add_env_var_paths (lang_env_vars[idx], INC_SYSTEM); > > target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc); where we pass cxx_stdinc=0 and cpp_pts->cplusplus==0 (and nobody complains anout that chatty cxx_stdinc=false and not =0 but so be it) I.e. we do honor both CPATH as well as C_INCLUDE_PATH from the env for fortran preprocessing. Maybe we should document this fact somehow as i do not think we want to change it? [ in gcc/doc/cppenv.texi: @itemx OBJC_INCLUDE_PATH @c Commented out until ObjC++ is part of GCC: @c @itemx OBJCPLUS_INCLUDE_PATH where i think objc++ is currently (still) in the tree so maybe someone may want to tweak the docs here. But i digress.. ] gcc/ada/gnat_ugn.texi documents caveats for globally set C_INCLUDE_PATH when using more than one compiler. [It's the only user of :envvar:`` in the tree, everybody else seems to use @env{} btw.] I cannot judge if ada is aware of pulling in CPATH or if maybe they somehow prevent this, didn't look. Thoughts on the env vars for fortran preprocessing? thanks, > > Bootstrapped and regtested on x86_64-unknown-linux without regressions. > Ok for tunk? > > Bernhard Reutner-Fischer (2): > Add free_cpp_dirs() > Fortran: Fix memory leak in gfc_add_include_path [PR68800] > > gcc/fortran/cpp.c | 13 +++++++++++-- > gcc/fortran/cpp.h | 1 + > gcc/fortran/f95-lang.c | 2 +- > gcc/fortran/scanner.c | 7 ++++--- > gcc/incpath.c | 13 +++++++++++++ > gcc/incpath.h | 1 + > 6 files changed, 31 insertions(+), 6 deletions(-) >