From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 30 06:17:00 2021 Received: (at submit) by debbugs.gnu.org; 30 Oct 2021 10:17:00 +0000 Received: from localhost ([127.0.0.1]:56660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglQ0-0001i5-Hw for submit@debbugs.gnu.org; Sat, 30 Oct 2021 06:17:00 -0400 Received: from lists.gnu.org ([209.51.188.17]:52642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgjvh-0007Xu-5l for submit@debbugs.gnu.org; Sat, 30 Oct 2021 04:41:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgjvg-0007ZZ-QV for bug-grep@gnu.org; Sat, 30 Oct 2021 04:41:32 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:44561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgjvb-00050F-Jj for bug-grep@gnu.org; Sat, 30 Oct 2021 04:41:32 -0400 Received: by mail-pf1-x42b.google.com with SMTP id a26so11440709pfr.11 for ; Sat, 30 Oct 2021 01:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rydHZpIHcKr1PI3P3tMNZhY7+ofMIxdqGAfikuxWBlU=; b=ahdAlPn0CKWqBQ+ZZdL4XVtSv6wHTK8c6sN0wXykuKaDhE/dXSN2rSkF9W44cadbrH 84Fz3Q5RzzThQ1q485Q2z8mqRO3BeZVD9osdIcogr8RpsK4sEZ5NDM3NmfAhHg3CbC0x R1piq5Nx2YMXlKRyRTQ25vzrue0Ft1UAVS2usT1YUgwKQg7sGPtRfXknth5pZhSiU/Qc 76+++LLBijTbQ7Rt33vpoPufzwoVVw+SrTcNmCzF57IgeuVxnNiU08TbmrMMG0FjbBGs 08esmpMqqtZWIB9S1CvE7nsiePDvMkuys9l3b/oHKQjxzPNv/RCe9IlqwGqW0aiEEHMs oMOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=rydHZpIHcKr1PI3P3tMNZhY7+ofMIxdqGAfikuxWBlU=; b=mJO0tD3NOO+JJNoOlHmTMWbpFICuYJAr5L8sLXwmMA+PeOIoFffuZNMNn1clAMU2G0 YqIovqDOYCGklp2ZLutW3OnY7Y2oMFtOHNJUu293owlde9i7EaDYQOzLxhTIflNQi3Rq B1UJjqyWixPBTlB8ACyWUy7bDOKUMDLGpsZzKRdGrx+PvyzHtxS7xKTMExpR6iSq/4UG G4sd/v4qQjn4keF5jcSAsahFTvaVBt+xD8QJPfB7X7N5SLYI3ofJwT8inBIKor6HilbH pLihbK6vaLWud+GEcSaf6LssmzhgE5aXT5cqgwH58f/975eFDaRlcd4ZKqiPouTr2Fxz 8XwA== X-Gm-Message-State: AOAM532kaHRYKnIbOHifI+25z1LOVTVVNGWTqTUiQy3SmZDub9qNDeIk oZRgBOxa6dWxHit19x+1h+TqwUc+j7U= X-Google-Smtp-Source: ABdhPJyZ1iKYsyNxWC83aS9l2kGXRkfAiJ4CtUyWZ/SW3j8LdyxpdApfcD7vwI6l/eohnMBg1UW0jA== X-Received: by 2002:aa7:8198:0:b0:44b:e191:7058 with SMTP id g24-20020aa78198000000b0044be1917058mr16221267pfi.39.1635583284921; Sat, 30 Oct 2021 01:41:24 -0700 (PDT) Received: from slk1.local.net (n110-23-108-30.sun3.vic.optusnet.com.au. [110.23.108.30]) by smtp.gmail.com with ESMTPSA id 125sm8974378pfv.155.2021.10.30.01.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Oct 2021 01:41:24 -0700 (PDT) From: Duncan Roe To: bug-grep@gnu.org Subject: grep not building for me with gcc 11.2 Date: Sat, 30 Oct 2021 19:40:25 +1100 Message-Id: <20211030084026.21464-1-duncan_roe@optusnet.com.au> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=duncan.roe2@gmail.com; helo=mail-pf1-x42b.google.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 30 Oct 2021 06:16:53 -0400 Cc: duncan.roe2@gmail.com, Duncan Roe X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) Straight away let me say I have gotten around this and can now build grep. But it toook me 2 days. The actual bug is that `CFLAGS=` causes configure to enable gcc warnings. I would then get multiline warnings like the one at end of this report. Because of -Werror, the build would then stop. I had been running configure as `CFLAGS='-g3 -ggdb' ./configure --disable-nls`. Eventually I tried plain `./configure` which built. Tests revealed simply `CFLAGS=-g ./configure` provokes the warnings. Now I run `CFLAGS='-g3 -ggdb' ./configure --disable-gcc-warnings --disable-nls`. To stop other folks running into this, configure.ac needs to be fixed to not --enable-gcc-warnings of its own accord. Cheers ... Duncan. ======================================== All the "error" lines flagged by gcc11.2 are false alarms. This is a list of them: > exclude.c:691:10: error: leak of FILE 'in' [CWE-775] [-Werror=analyzer-file-leak] > fts.c:1497:25: error: use of NULL 'cp' where non-null expected [CWE-476] [-Werror=analyzer-null-argument] > regex_internal.c:992:17: error: dereference of possibly-NULL 'next_nodes.elems' [CWE-690] [-Werror=analyzer-possible-null-dereference] > regex_internal.c:992:17: error: dereference of possibly-NULL '*dests_node.elems' [CWE-690] [-Werror=analyzer-possible-null-dereference] > regex_internal.c:992:17: error: dereference of possibly-NULL 'union_set.elems' [CWE-690] [-Werror=analyzer-possible-null-dereference] > regex_internal.c:992:17: error: dereference of possibly-NULL '*set.elems' [CWE-690] [-Werror=analyzer-possible-null-dereference] > regex_internal.c:992:17: error: dereference of possibly-NULL '*set.elems' [CWE-690] [-Werror=analyzer-possible-null-dereference] > regex_internal.c:992:17: error: dereference of possibly-NULL 'new_nodes.elems' [CWE-690] [-Werror=analyzer-possible-null-dereference] > regex_internal.c:1040:7: error: use of possibly-NULL 'next_nodes.elems' where non-null expected [CWE-690] [-Werror=analyzer-possible-null-argument] > regex_internal.c:1040:7: error: use of possibly-NULL '*dest.elems' where non-null expected [CWE-690] [-Werror=analyzer-possible-null-argument] These are all in gnulib. The following patch eliminates all of them, but don't apply it. The patch is to highlight code constructs that gcc can't analyse adequately. Should I report these to the gcc team? They tend to like simple sources with no headers and so on - I don't know if I can find the time to do that. But maybe I could do 1 or 2. At least it's their own source (gnu's, not gcc's). ======================================== Here's an analysis of the first alleged error. add_exclude_file() is a short function: > int > add_exclude_file (void (*add_func) (struct exclude *, char const *, int), > struct exclude *ex, char const *file_name, int options, > char line_end) > { > bool use_stdin = file_name[0] == '-' && !file_name[1]; > FILE *in; > int rc = 0; > > if (use_stdin) > in = stdin; > else if (! (in = fopen (file_name, "re"))) > return -1; > > rc = add_exclude_fp (call_addfn, ex, in, options, line_end, &add_func); > > if (!use_stdin && fclose (in) != 0) > rc = -1; > > return rc; > } If `use_stdin` is false then `in` becomes the fd of some file. But if `use_stdin` is false, then `in` is rigorously closed. So there can be no file leak. > In function 'add_exclude_file': > exclude.c:691:10: error: leak of FILE 'in' [CWE-775] [-Werror=analyzer-file-leak] > 691 | return rc; > | ^~ > 'add_exclude_file': events 1-8 > | > | 673 | add_exclude_file (void (*add_func) (struct exclude *, char const *, int), > | | ^~~~~~~~~~~~~~~~ > | | | > | | (1) entry to 'add_exclude_file' > |...... > | 681 | if (use_stdin) > | | ~ > | | | > | | (2) following 'false' branch (when 'use_stdin == 0')... > | 682 | in = stdin; > | 683 | else if (! (in = fopen (file_name, "re"))) > | | ~ ~~~~~~~~~~~~~~~~~~~~~~~ > | | | | > | | | (3) ...to here > | | | (4) opened here > | | (5) assuming 'in' is non-NULL > | | (6) following 'false' branch (when 'in' is non-NULL)... > |...... > | 686 | rc = add_exclude_fp (call_addfn, ex, in, options, line_end, &add_func); > | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | | > | | (7) ...to here > | | (8) calling 'add_exclude_fp' from 'add_exclude_file' > | > +--'add_exclude_fp': event 9 > | > | 608 | add_exclude_fp (void (*add_func) (struct exclude *, char const *, int, void *), > | | ^~~~~~~~~~~~~~ > | | | > | | (9) entry to 'add_exclude_fp' > | > 'add_exclude_fp': events 10-16 > | > | 622 | while ((c = getc (fp)) != EOF) > | | ^ > | | | > | | (10) following 'false' branch (when 'c == -1')... > |...... > | 629 | if (ferror (fp)) > | | ~~~~~~~~~~~ > | | | > | | (11) ...to here > |...... > | 634 | lim = buf + buf_count + ! (buf_count == 0 || buf[buf_count - 1] == line_end); > | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | | > | | (12) following 'false' branch (when 'buf_count == 0')... > | | (13) ...to here > |...... > | 640 | for (p = buf; p < lim; p++) > | | ~~~~~~~ > | | | > | | (16) following 'false' branch (when 'p >= lim')... > | 641 | if (*p == line_end) > | | ~ > | | | > | | (14) following 'true' branch... > | 642 | { > | 643 | char *pattern_end = p; > | | ~~~~~~~~~~~ > | | | > | | (15) ...to here > | > 'add_exclude_fp': event 17 > | > | 661 | errno = e; > | | ^~~~~ > | | | > | | (17) ...to here > | > <------+ > | > 'add_exclude_file': events 18-21 > | > | 686 | rc = add_exclude_fp (call_addfn, ex, in, options, line_end, &add_func); > | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | | > | | (18) returning to 'add_exclude_file' from 'add_exclude_fp' > | 687 | > | 688 | if (!use_stdin && fclose (in) != 0) > | | ~ > | | | > | | (19) following 'false' branch... > |...... > | 691 | return rc; > | | ~~ > | | | > | | (20) ...to here > | | (21) 'in' leaks here; was opened at (4) > | > 13:51:11$ gcc --version > gcc (GCC) 11.2.0 Duncan Roe (1): Silly patch to avoid some gcc 11.2 warnings lib/exclude.c | 9 +++++++-- lib/fts.c | 2 +- lib/regex_internal.c | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) -- 2.33.1 From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 30 20:41:35 2021 Received: (at 51504-done) by debbugs.gnu.org; 31 Oct 2021 00:41:35 +0000 Received: from localhost ([127.0.0.1]:58676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgyui-0007oL-IY for submit@debbugs.gnu.org; Sat, 30 Oct 2021 20:41:35 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:48686) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgyud-0007o5-EO for 51504-done@debbugs.gnu.org; Sat, 30 Oct 2021 20:41:31 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E36141600EB; Sat, 30 Oct 2021 17:41:21 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id g5rO8Ifh4Qc6; Sat, 30 Oct 2021 17:41:16 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E1AEC1600FC; Sat, 30 Oct 2021 17:41:15 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id x9SlZj5F4Q3f; Sat, 30 Oct 2021 17:41:14 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E82351600EB; Sat, 30 Oct 2021 17:41:13 -0700 (PDT) Message-ID: <22278390-cb5e-ef31-aed8-10d0ac8f3e4a@cs.ucla.edu> Date: Sat, 30 Oct 2021 17:41:13 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Content-Language: en-US To: Duncan Roe References: <20211030084026.21464-1-duncan_roe@optusnet.com.au> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#51504: grep not building for me with gcc 11.2 In-Reply-To: <20211030084026.21464-1-duncan_roe@optusnet.com.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 51504-done Cc: duncan.roe2@gmail.com, 51504-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 10/30/21 01:40, Duncan Roe wrote: > To stop other folks running into this, configure.ac needs to be fixed to not > --enable-gcc-warnings of its own accord. configure.ac enables GCC warnings by default only you're building from a Git repository. If you had built from the latest grep release tarball you wouldn't have run into this problem. This should be documented better in README-hacking. I installed a patch to GNU grep to try to do that. See: https://git.savannah.gnu.org/cgit/grep.git/commit/?id=1ba972edec7867c1592083363dc9fadfebf77e2e > Should I report these to the gcc team? I wouldn't bother. The grep sources are tuned for --enable-gcc-warnings with -O2 and no other optimization-relevant options. From unknown Fri Jun 20 05:29:00 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 28 Nov 2021 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator