public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* elfutils does not compile with gcc 12.2.0
@ 2022-08-24 20:51 Nick
  2022-08-24 21:01 ` Dmitry V. Levin
  0 siblings, 1 reply; 3+ messages in thread
From: Nick @ 2022-08-24 20:51 UTC (permalink / raw)
  To: elfutils-devel

I try to compile elfutils on OpenWrt with the newest gcc 12.2.0 version. 
However, it fails due to -Werror=use-after-free. A workaround is a patch 
that I found on the mailinglist, to disable -Werror 
(https://sourceware.org/legacy-ml/elfutils-devel/imported/msg00994.html) 
I modified it to apply to newest elfutils version. The error with 
elfutils 0.187 and gcc 12.2.0:

In function 'bigger_buffer',
     inlined from '__libdw_gunzip' at gzip.c:376:12:
gzip.c:98:9: error: pointer may be used after 'realloc' 
[-Werror=use-after-free]
    98 |     b = realloc (state->buffer, more -= 1024);
       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gzip.c:96:13: note: call to 'realloc' here
    96 |   char *b = realloc (state->buffer, more);
       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: all warnings being treated as errors

Can you apply the patch to disable werror? Or is it necessary to use 
some "#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free""-statement?

Bests
Nick




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: elfutils does not compile with gcc 12.2.0
  2022-08-24 20:51 elfutils does not compile with gcc 12.2.0 Nick
@ 2022-08-24 21:01 ` Dmitry V. Levin
  2022-08-25  8:51   ` Nick
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry V. Levin @ 2022-08-24 21:01 UTC (permalink / raw)
  To: elfutils-devel

On Wed, Aug 24, 2022 at 10:51:13PM +0200, Nick via Elfutils-devel wrote:
> I try to compile elfutils on OpenWrt with the newest gcc 12.2.0 version. 
> However, it fails due to -Werror=use-after-free. A workaround is a patch 
> that I found on the mailinglist, to disable -Werror 
> (https://sourceware.org/legacy-ml/elfutils-devel/imported/msg00994.html) 
> I modified it to apply to newest elfutils version. The error with 
> elfutils 0.187 and gcc 12.2.0:
> 
> In function 'bigger_buffer',
>      inlined from '__libdw_gunzip' at gzip.c:376:12:
> gzip.c:98:9: error: pointer may be used after 'realloc' 
> [-Werror=use-after-free]
>     98 |     b = realloc (state->buffer, more -= 1024);
>        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> gzip.c:96:13: note: call to 'realloc' here
>     96 |   char *b = realloc (state->buffer, more);
>        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This warning is definitely wrong, looks like a regression in gcc, please
report this to compiler people, otherwise they will never know they
introduced a bug that needs fixing.


-- 
ldv


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: elfutils does not compile with gcc 12.2.0
  2022-08-24 21:01 ` Dmitry V. Levin
@ 2022-08-25  8:51   ` Nick
  0 siblings, 0 replies; 3+ messages in thread
From: Nick @ 2022-08-25  8:51 UTC (permalink / raw)
  To: Dmitry V. Levin, elfutils-devel

On 8/24/22 23:01, Dmitry V. Levin wrote:

> On Wed, Aug 24, 2022 at 10:51:13PM +0200, Nick via Elfutils-devel wrote:
>> I try to compile elfutils on OpenWrt with the newest gcc 12.2.0 version.
>> However, it fails due to -Werror=use-after-free. A workaround is a patch
>> that I found on the mailinglist, to disable -Werror
>> (https://sourceware.org/legacy-ml/elfutils-devel/imported/msg00994.html)
>> I modified it to apply to newest elfutils version. The error with
>> elfutils 0.187 and gcc 12.2.0:
>>
>> In function 'bigger_buffer',
>>       inlined from '__libdw_gunzip' at gzip.c:376:12:
>> gzip.c:98:9: error: pointer may be used after 'realloc'
>> [-Werror=use-after-free]
>>      98 |     b = realloc (state->buffer, more -= 1024);
>>         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> gzip.c:96:13: note: call to 'realloc' here
>>      96 |   char *b = realloc (state->buffer, more);
>>         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This warning is definitely wrong, looks like a regression in gcc, please
> report this to compiler people, otherwise they will never know they
> introduced a bug that needs fixing.
I think it is not the only failure. I added a comment under this already 
existing bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104069#c24

If you look at this comment I am not sure if that is ever fixed:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104069#c20
The write here about using "pragma" statements to suppress the warning.
What about introducing the disabling of werror by a configure flag?

Bests
Nick


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-25  8:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24 20:51 elfutils does not compile with gcc 12.2.0 Nick
2022-08-24 21:01 ` Dmitry V. Levin
2022-08-25  8:51   ` Nick

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).