public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/104069] Wuse-after-free=2 -O0 false positive "may be used"
Date: Fri, 12 May 2023 20:36:39 +0000	[thread overview]
Message-ID: <bug-104069-4-4e2gUGYOj4@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104069-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104069

--- Comment #32 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Created attachment 55068
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55068&action=edit
gzip.c.c

> > You should be able to extract preprocessed file using
> > https://gcc.gnu.org/bugs/#need: you will need to find exact `gcc` invocation
> > that causes build failure, add `-save-temps` parameter to it, grab '*.i'
> > file and attach it along with exact command you used to produce it.
> 
> That gcc page does not say how to extract the command from the makefile that
> triggers the error, so I've tried to reproduce this bug manually and after
> like the 8th attempt when all the header files were finally found by the
> compiler, the linker errored out with some undefined references, so no luck.
> The good new is that this error is reproducible if the
> cflags/ldflags/configure...etc switches set up like in c#29

gcc help can't cover specifics of external build systems. You have to have a
bit of expertise to extract the actual command build system runs.

As elfutils is an automake-maked '$ make V=1' will print you every gcc command
the build system is running. It should be in a form you can copy and paste as
is (modulo current directory and a few environment variables).

I think I reproduced it on gcc-12.2.0 and elfutils-0.189. Attached as gzip.c.c.

Trigger on gcc-12.2.0:

$ gcc  -std=gnu99 -Wall  -Werror -Os -mtune=generic -c gzip.c.c
In function 'bigger_buffer',
    inlined from '__libdw_gunzip' at gzip.c.c:7751:13:
gzip.c.c:7609:13: error: pointer may be used after 'realloc'
[-Werror=use-after-free]
 7609 |         b = realloc (state->buffer, more -= 1024);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gzip.c.c:7605:15: note: call to 'realloc' here
 7605 |     char *b = realloc (state->buffer, more);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

gcc-master does not seem to reproduce the failure. I did not test gcc-13.

  parent reply	other threads:[~2023-05-12 20:36 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 17:18 [Bug c/104069] New: -Werror=use-after-free false positive on elfutils-0.186 slyfox at gcc dot gnu.org
2022-01-17 17:27 ` [Bug tree-optimization/104069] " pinskia at gcc dot gnu.org
2022-01-17 17:29 ` slyfox at gcc dot gnu.org
2022-01-17 19:10 ` msebor at gcc dot gnu.org
2022-01-17 21:52 ` msebor at gcc dot gnu.org
2022-01-18  9:37 ` slyfox at gcc dot gnu.org
2022-01-18 22:03 ` msebor at gcc dot gnu.org
2022-01-18 22:06 ` [Bug middle-end/104069] " msebor at gcc dot gnu.org
2022-01-18 22:17 ` jakub at gcc dot gnu.org
2022-01-18 22:47 ` msebor at gcc dot gnu.org
2022-01-18 22:56 ` jakub at gcc dot gnu.org
2022-01-19  0:51 ` amacleod at redhat dot com
2022-01-19  1:04 ` cvs-commit at gcc dot gnu.org
2022-01-19 20:22 ` msebor at gcc dot gnu.org
2022-01-19 20:24 ` msebor at gcc dot gnu.org
2022-01-19 20:30 ` pinskia at gcc dot gnu.org
2022-01-19 20:31 ` pinskia at gcc dot gnu.org
2022-01-19 20:32 ` msebor at gcc dot gnu.org
2022-01-19 20:34 ` jakub at gcc dot gnu.org
2022-01-19 20:42 ` jakub at gcc dot gnu.org
2022-01-19 20:54 ` msebor at gcc dot gnu.org
2022-01-31 11:18 ` jakub at gcc dot gnu.org
2022-03-17 19:32 ` msebor at gcc dot gnu.org
2022-05-16 14:14 ` eike@sf-mail.de
2022-08-24  8:51 ` vincent at systemli dot org
2022-10-27 16:57 ` mark at gcc dot gnu.org
2022-10-28  7:36 ` slyfox at gcc dot gnu.org
2023-05-10  3:35 ` [Bug middle-end/104069] Wuse-after-free=2 -O0 false positive "may be used" mkaracsony81 at gmail dot com
2023-05-12  7:00 ` slyfox at gcc dot gnu.org
2023-05-12  8:30 ` mkaracsony81 at gmail dot com
2023-05-12  9:08 ` slyfox at gcc dot gnu.org
2023-05-12 13:20 ` mkaracsony81 at gmail dot com
2023-05-12 20:36 ` slyfox at gcc dot gnu.org [this message]
2023-05-13  5:07 ` mkaracsony81 at gmail dot com
2023-05-13  5:07 ` mkaracsony81 at gmail dot com
2023-12-17  4:40 ` lavr at ncbi dot nlm.nih.gov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104069-4-4e2gUGYOj4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).