glibc 2.36 build failure on Fedora 36 with gcc 12 (-Werror=use-after-free)

Paul Eggert eggert@cs.ucla.edu
Fri Jul 29 16:39:35 GMT 2022


On 7/29/22 08:26, Carlos O'Donell via Libc-alpha wrote:
> Just posting here for the record that I see a glibc 2.36 build failure
> with Fedora 36 and gcc 12.
> 
> localealias.c: In function ‘read_alias_file’:
> localealias.c:335:56: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
>    335 |                               map[i].alias += new_pool - string_space;
>        |                                               ~~~~~~~~~^~~~~~~~~~~~~~
> localealias.c:325:49: note: call to ‘realloc’ here
>    325 |                       char *new_pool = (char *) realloc (string_space, new_size);
>        |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> I'm going to review this quickly before we make the glibc release.
> 

One option is to fix the conformance bug rather than continue to try to 
paper it over with a pragma.

In looking into it, I found two kinds of conformance bugs in 
localealias.c: first, accessing a realloced pointer (which GCC warns 
about), and second, calling a function via an incompatible function 
pointer (which GCC doesn't warn about). Proposed patch attached. I have 
compiled but not tested this.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Avoid-undefined-behavior-in-localealias.c.patch
Type: text/x-patch
Size: 5831 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20220729/4527fe0d/attachment.bin>


More information about the Libc-alpha mailing list