Subject: sysdep.c:1821:22: error: variably modified ‘sigsegv_stack’ at file scope

From: Håkon Hægland <[email-masked]>
Date: Sun, 17 Oct 2021 22:49:08 +0200

I am trying to install emacs 27.2 from source on Ubuntu 21.10:

$ gcc --version
gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0

$ wget http://ftp.gnu.org/gnu/emacs/emacs-27.2.tar.gz
$ tar zvxf emacs-27.2.tar.gz
$ cd emacs-27.2
$ ./configure --prefix=/opt/emacs27.2
$ make
make -C lib all
make[1]: Entering directory '/home/hakon/test/install_emacs/emacs-27.2/lib'
  GEN      alloca.h
  GEN      dirent.h
  GEN      fcntl.h
  GEN      inttypes.h
  GEN      limits.h
  GEN      signal.h
  GEN      stdio.h
  GEN      stdlib.h
  GEN      string.h
  GEN      sys/select.h
  GEN      sys/stat.h
  GEN      sys/time.h
  GEN      sys/types.h
  GEN      time.h
  GEN      unistd.h
  CC       fingerprint.o
  CC       fcntl.o
  CC       fsusage.o
  CC       regex.o
  CC       sig2str.o
  CC       time_rz.o
  CC       acl-errno-valid.o
  CC       acl-internal.o
  CC       get-permissions.o
  CC       set-permissions.o
  CC       allocator.o
  CC       binary-io.o
  CC       c-ctype.o
  CC       c-strcasecmp.o
  CC       c-strncasecmp.o
  CC       careadlinkat.o
careadlinkat.c: In function ‘careadlinkat’:
cc1: warning: function may return address of local variable
[-Wreturn-local-addr]
careadlinkat.c:73:8: note: declared here
   73 |   char stack_buf[1024];
      |        ^~~~~~~~~
  CC       close-stream.o
  CC       count-leading-zeros.o
  CC       count-one-bits.o
  CC       count-trailing-zeros.o
  CC       md5.o
  CC       sha1.o
  CC       sha256.o
  CC       sha512.o
  CC       dtoastr.o
  CC       dtotimespec.o
  CC       filemode.o
  CC       filevercmp.o
  CC       gettime.o
  CC       nstrftime.o
  CC       pipe2.o
  CC       qcopy-acl.o
  CC       stat-time.o
  CC       tempname.o
  CC       timespec.o
  CC       timespec-add.o
  CC       timespec-sub.o
  CC       u64.o
  CC       unistd.o
  CC       utimens.o
utimens.c: In function ‘fdutimens’:
utimens.c:382:17: warning: ‘update_timespec’ accessing 16 bytes in a region
of size 8 [-Wstringop-overflow=]
  382 |       if (ts && update_timespec (&st, &ts))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
utimens.c:382:17: note: referencing argument 2 of type ‘struct timespec **’
utimens.c:133:1: note: in a call to function ‘update_timespec’
  133 | update_timespec (struct stat const *statbuf, struct timespec *ts[2])
      | ^~~~~~~~~~~~~~~
utimens.c: In function ‘lutimens’:
utimens.c:595:17: warning: ‘update_timespec’ accessing 16 bytes in a region
of size 8 [-Wstringop-overflow=]
  595 |       if (ts && update_timespec (&st, &ts))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
utimens.c:595:17: note: referencing argument 2 of type ‘struct timespec **’
utimens.c:133:1: note: in a call to function ‘update_timespec’
  133 | update_timespec (struct stat const *statbuf, struct timespec *ts[2])
      | ^~~~~~~~~~~~~~~
  CC       openat-die.o
  CC       save-cwd.o
  AR       libgnu.a
make[1]: Leaving directory '/home/hakon/test/install_emacs/emacs-27.2/lib'
make -C lib-src all
make[1]: Entering directory
'/home/hakon/test/install_emacs/emacs-27.2/lib-src'
  CCLD     etags
  CCLD     ctags
etags.c: In function ‘main’:
cc1: warning: ‘__builtin_memcpy’ writing 12 bytes into a region of size
between 0 and 7 [-Wstringop-overflow=]
In file included from ctags.c:2:
etags.c:1395:21: note: destination object of size [0, 7] allocated by
‘xmalloc’
 1395 |         char *cmd = xmalloc (2 * strlen (tagfile) + sizeof "sort -u
-o..");
      |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
etags.c:1401:14: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
 1401 |         *z++ = ' ';
      |         ~~~~~^~~~~
etags.c:1395:21: note: at offset 11 into destination object of size [0, 7]
allocated by ‘xmalloc’
 1395 |         char *cmd = xmalloc (2 * strlen (tagfile) + sizeof "sort -u
-o..");
      |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:519,
                 from ../lib/string.h:41,
                 from etags.c:120,
                 from ctags.c:2:
In function ‘stpcpy’,
    inlined from ‘main’ at etags.c:1400:6:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:86:10: warning:
‘__builtin_stpcpy’ writing 1 or more bytes into a region of size 0
overflows the destination [-Wstringop-overflow=]
   86 |   return __builtin___stpcpy_chk (__dest, __src, __glibc_objsize
(__dest));
      |
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ctags.c:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h: In function ‘main’:
etags.c:1395:21: note: at offset 11 into destination object of size [0, 7]
allocated by ‘xmalloc’
 1395 |         char *cmd = xmalloc (2 * strlen (tagfile) + sizeof "sort -u
-o..");
      |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:519,
                 from ../lib/string.h:41,
                 from etags.c:120,
                 from ctags.c:2:
In function ‘strcpy’,
    inlined from ‘main’ at etags.c:1402:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:79:10: warning:
‘__builtin_strcpy’ writing 1 or more bytes into a region of size 0
overflows the destination [-Wstringop-overflow=]
   79 |   return __builtin___strcpy_chk (__dest, __src, __glibc_objsize
(__dest));
      |
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ctags.c:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h: In function ‘main’:
etags.c:1395:21: note: at offset 12 into destination object of size [0, 7]
allocated by ‘xmalloc’
 1395 |         char *cmd = xmalloc (2 * strlen (tagfile) + sizeof "sort -u
-o..");
      |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CCLD     emacsclient
  CCLD     ebrowse
  CCLD     hexl
  CC       pop.o
  CCLD     movemail
  CCLD     make-docfile
  CCLD     make-fingerprint
make[1]: Leaving directory
'/home/hakon/test/install_emacs/emacs-27.2/lib-src'
make -C src VCSWITNESS='' all
make[1]: Entering directory '/home/hakon/test/install_emacs/emacs-27.2/src'
  GEN      lisp.mk
  GEN      globals.h
  CC       dispnew.o
  CC       frame.o
  CC       scroll.o
  CC       xdisp.o
  CC       menu.o
  CC       xmenu.o
  CC       window.o
  CC       charset.o
  CC       coding.o
  CC       category.o
  CC       ccl.o
  CC       character.o
  CC       chartab.o
  CC       bidi.o
  CC       cm.o
  CC       term.o
  CC       terminal.o
  CC       xfaces.o
  CC       xterm.o
  CC       xfns.o
  CC       xselect.o
  CC       xrdb.o
  CC       xsmfns.o
  CC       xsettings.o
  CC       gtkutil.o
  CC       emacsgtkfixed.o
  CC       dbusbind.o
  CC       emacs.o
  CC       keyboard.o
  CC       macros.o
  CC       keymap.o
  CC       sysdep.o
sysdep.c:1821:22: error: variably modified ‘sigsegv_stack’ at file scope
 1821 | static unsigned char sigsegv_stack[SIGSTKSZ];
      |                      ^~~~~~~~~~~~~
make[1]: *** [Makefile:406: sysdep.o] Error 1
make[1]: Leaving directory '/home/hakon/test/install_emacs/emacs-27.2/src'
make: *** [Makefile:424: src] Error 2