crash-utility / crash

Linux kernel crash utility
https://crash-utility.github.io
788 stars 266 forks source link

/usr/include/bits/string_fortified.h:143:38: error: expected ')' before string constant #137

Closed vt-alt closed 1 year ago

vt-alt commented 1 year ago

When building last released version of crash-8.0.3 on gcc version 12.2.1 20230322 error appears:

  CC       save-cwd.o
  CC       malloc/scratch_buffer_grow.o
  CC       malloc/scratch_buffer_grow_preserve.o
In file included from /usr/include/string.h:548,
                 from ./string.h:41,
                 from malloc/scratch_buffer_grow_preserve.c:25:
/usr/include/bits/string_fortified.h:143:38: error: expected ')' before string constant
  143 | __warndecl (__warn_strlcpy_size_zero,
      |                                      ^
      |                                      )
  144 |             "strlcpy used with a size argument of zero");
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bits/string_fortified.h:145:39: error: expected ')' before string constant
  145 | __warndecl (__warn_strlcpy_size_large,
      |                                       ^
      |                                       )
  146 |             "strlcpy used with a size argument which is too large");
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bits/string_fortified.h:170:38: error: expected ')' before string constant
  170 | __warndecl (__warn_strlcat_size_zero,
      |                                      ^
      |                                      )
  171 |             "strlcat used with a size argument of zero");
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bits/string_fortified.h:172:39: error: expected ')' before string constant
  172 | __warndecl (__warn_strlcat_size_large,
      |                                       ^
      |                                       )
  173 |             "strlcat used with a size argument which is too large");
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[8]: *** [Makefile:2012: malloc/scratch_buffer_grow_preserve.o] Error 1
vt-alt commented 1 year ago

It seems that previous version didn't even try to compile scratch_buffer_grow_preserve.

k-hagio commented 1 year ago

hmm, it cannot be reproduced on Fedora 37 with gcc-12.2.1-2.fc37.x86_64, though many warnings are emitted..

$ make warn
...
  CC       save-cwd.o
  CC       malloc/scratch_buffer_grow.o
  CC       malloc/scratch_buffer_grow_preserve.o
  CC       malloc/scratch_buffer_set_array_size.o
  CC       setlocale_null.o
...
vt-alt commented 1 year ago

Thanks to note that, I will try to find the difference between setups.

vt-alt commented 1 year ago

Offending lines in /usr/include/bits/string_fortified.h are

   142  #ifdef __USE_MISC
   143  __warndecl (__warn_strlcpy_size_zero,
   144              "strlcpy used with a size argument of zero");
   145  __warndecl (__warn_strlcpy_size_large,
   146              "strlcpy used with a size argument which is too large");
   147  extern size_t __strlcpy_chk (char *__dest, const char *__src, size_t __n,
   148                               size_t __destlen) __THROW;
   149  extern size_t __REDIRECT_NTH (__strlcpy_alias,
   150                                (char *__dest, const char *__src, size_t __n),
   151                                strlcpy);

This seem related to that in bundled gdb's libc-config.h (part of gnulib, which in turn is imported from glibc) where __warndecl is undefined, thus making these (and following) statements fail.

I wonder how this should be approached though.

vt-alt commented 1 year ago

This is so peculiar to ALT perhaps I should just hack it around. So I did:

diff --git a/Makefile b/Makefile
index a94a243c24..d245bea6e1 100644
--- a/Makefile
+++ b/Makefile
@@ -293,6 +293,7 @@ gdb_unzip:
 gdb_patch:
     if [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \
         patch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi
+    sed -i '/warndecl/d' gdb-*/gnulib/import/libc-config.h

 library: ${OBJECT_FILES}
     ar -rs ${PROGRAM}lib.a ${OBJECT_FILES}