public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Wrong warning in open_catalog.c with trunk GCC?
@ 2023-04-01 19:09 Jan-Benedict Glaw
  2023-04-01 19:18 ` Sam James
  0 siblings, 1 reply; 3+ messages in thread
From: Jan-Benedict Glaw @ 2023-04-01 19:09 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 10617 bytes --]

Hi!

With the CI builds, after supplying --disable-gcov to gcc-first, I see
this while building glibc:


x86_64-glibc-linux-gnu-gcc open_catalog.c -c -std=gnu11 -fgnu89-inline  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wstrict-prototypes -Wold-style-definition -fmath-errno    -fPIE   -ftls-model=initial-exec     -DNLSPATH='"/usr/share/locale/%L/%N:/usr/share/locale/%L/LC_MESSAGES/%N:/usr/share/locale/%l/%N:/usr/share/locale/%l/LC_MESSAGES/%N:"' -I../include -I/var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/build/compilers/x86_64-linux-gnu/glibc/x86_64-linux-gnu/catgets  -I/var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/build/compilers/x86_64-linux-gnu/glibc/x86_64-linux-gnu  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86/include -I../sysdeps/x86  -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.  -D_LIBC_REENTRANT -include /var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/build/compilers/x86_64-linux-gnu/glibc/x86_64-linux-gnu/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/build/compilers/x86_64-linux-gnu/glibc/x86_64-linux-gnu/catgets/open_catalog.o -MD -MP -MF /var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/build/compilers/x86_64-linux-gnu/glibc/x86_64-linux-gnu/catgets/open_catalog.o.dt -MT /var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/build/compilers/x86_64-linux-gnu/glibc/x86_64-linux-gnu/catgets/open_catalog.o
open_catalog.c: In function ‘__open_catalog’:
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:86:15: note: in expansion of macro ‘ENOUGH’
   86 |               ENOUGH (len);
      |               ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:86:15: note: in expansion of macro ‘ENOUGH’
   86 |               ENOUGH (len);
      |               ^~~~~~
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:102:23: note: in expansion of macro ‘ENOUGH’
  102 |                       ENOUGH (len);
      |                       ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:102:23: note: in expansion of macro ‘ENOUGH’
  102 |                       ENOUGH (len);
      |                       ^~~~~~
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:109:23: note: in expansion of macro ‘ENOUGH’
  109 |                       ENOUGH (len);
      |                       ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:109:23: note: in expansion of macro ‘ENOUGH’
  109 |                       ENOUGH (len);
      |                       ^~~~~~
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:118:27: note: in expansion of macro ‘ENOUGH’
  118 |                           ENOUGH (1);
      |                           ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:118:27: note: in expansion of macro ‘ENOUGH’
  118 |                           ENOUGH (1);
      |                           ^~~~~~
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:134:31: note: in expansion of macro ‘ENOUGH’
  134 |                               ENOUGH (1);
      |                               ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:134:31: note: in expansion of macro ‘ENOUGH’
  134 |                               ENOUGH (1);
      |                               ^~~~~~
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:151:31: note: in expansion of macro ‘ENOUGH’
  151 |                               ENOUGH (1);
      |                               ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:151:31: note: in expansion of macro ‘ENOUGH’
  151 |                               ENOUGH (1);
      |                               ^~~~~~
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:158:23: note: in expansion of macro ‘ENOUGH’
  158 |                       ENOUGH (1);
      |                       ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:158:23: note: in expansion of macro ‘ENOUGH’
  158 |                       ENOUGH (1);
      |                       ^~~~~~
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:171:19: note: in expansion of macro ‘ENOUGH’
  171 |                   ENOUGH (1);
      |                   ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:171:19: note: in expansion of macro ‘ENOUGH’
  171 |                   ENOUGH (1);
      |                   ^~~~~~
open_catalog.c:64:11: error: pointer ‘old_buf’ may be used after ‘realloc’ [-Werror=use-after-free]
   64 |           free (old_buf);                                                     \
      |           ^~~~~~~~~~~~~~
open_catalog.c:175:11: note: in expansion of macro ‘ENOUGH’
  175 |           ENOUGH (1);
      |           ^~~~~~
open_catalog.c:61:13: note: call to ‘realloc’ here
   61 |       buf = realloc (buf, bufmax);                                            \
      |             ^~~~~~~~~~~~~~~~~~~~~
open_catalog.c:175:11: note: in expansion of macro ‘ENOUGH’
  175 |           ENOUGH (1);
      |           ^~~~~~
cc1: all warnings being treated as errors
make[3]: *** [../o-iterator.mk:9: /var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/build/compilers/x86_64-linux-gnu/glibc/x86_64-linux-gnu/catgets/open_catalog.o] Error 1
make[3]: Leaving directory '/var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/src/glibc/catgets'
make[2]: *** [Makefile:484: catgets/subdir_lib] Error 2
make[2]: Leaving directory '/var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/src/glibc'
make[1]: *** [Makefile:9: all] Error 2
make[1]: Leaving directory '/var/lib/laminar/run/glibcbot-x86_64-linux-gnu/10/build/compilers/x86_64-linux-gnu/glibc/x86_64-linux-gnu'

FAIL: compilers-x86_64-linux-gnu glibc x86_64-linux-gnu build


That's when calling the ENOUGH() macro:

 56 #define ENOUGH(n)                                                             \
 57   if (__glibc_unlikely (bufact + (n) >= bufmax))                              \
 58     {                                                                         \
 59       char *old_buf = buf;                                                    \
 60       bufmax += (bufmax < 256 + (n)) ? 256 + (n) : bufmax;                    \
 61       buf = realloc (buf, bufmax);                                            \
 62       if (__glibc_unlikely (buf == NULL))                                     \
 63         {                                                                     \
 64           free (old_buf);                                                     \
 65           return -1;                                                          \
 66         }                                                                     \
 67     }


I don't spot an issue there. Maybe recent GCCs get confused over
__glibc_unlikely()?

Thanks,
  Jan-Benedict

-- 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2023-04-01 20:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-01 19:09 Wrong warning in open_catalog.c with trunk GCC? Jan-Benedict Glaw
2023-04-01 19:18 ` Sam James
2023-04-01 20:20   ` Jan-Benedict Glaw

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