From dd4e3abc5cd4f52ac9ed5fdee41b16c26165801e Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Tue, 30 Jun 2020 15:09:56 -0400 Subject: [PATCH] commit bash-20200626 snapshot --- CWRU/CWRU.chlog | 19 +++++++++++++++++++ Makefile.in | 10 +++++----- aclocal.m4 | 11 ++++++++--- configure | 38 ++++++++++++++++++++++++++++++++------ configure.ac | 5 ++++- doc/bashref.texi | 6 ------ examples/loadables/finfo.c | 6 +++--- unwind_prot.c | 2 ++ xmalloc.c | 10 +++++----- 9 files changed, 78 insertions(+), 29 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index a4436be1..e524c62f 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -8610,3 +8610,22 @@ lib/sh/zcatfd.c lib/sh/zmapfd.c - zmapfd: lbuf: bump size up to ZBUFSIZ (default 4096) + + 6/29 + ---- +aclocal.m4 + - BASH_FUNC_SBRK: changes for cross-compiling on FreeBSD variants, + from Jessica Clarke + +xmalloc.c + - HAVE_SBRK: use #if instead of #ifdef so we only use it if we think + it works + +examples/loadables/finfo.c + - st_dev,st_nlink: cast to unsigned long, report from Jessica Clarke + + +unwind_prot.c + - unwind_protect_mem_internal: make sure we allocate at least as many + bytes for an entire UNWIND_ELT. Fix from Jessica Clarke + diff --git a/Makefile.in b/Makefile.in index 3a3ec754..087a4002 100644 --- a/Makefile.in +++ b/Makefile.in @@ -760,7 +760,7 @@ Makefile makefile: config.status $(srcdir)/Makefile.in Makefiles makefiles: config.status $(srcdir)/Makefile.in @for mf in $(CREATED_MAKEFILES); do \ - CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status ; \ + CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status || exit 1; \ done config.h: stamp-h @@ -846,16 +846,16 @@ install-headers-dirs: install-headers: install-headers-dirs @for hf in $(INSTALLED_HEADERS) ; do \ - ${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \ + ${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \ done @for hf in $(INSTALLED_INCFILES) ; do \ - ${INSTALL_DATA} $(BASHINCDIR)/"$$hf" $(DESTDIR)$(headersdir)/include/$$hf; \ + ${INSTALL_DATA} $(BASHINCDIR)/"$$hf" $(DESTDIR)$(headersdir)/include/$$hf || exit 1; \ done @for hf in $(INSTALLED_BUILTINS_HEADERS) ; do \ - ${INSTALL_DATA} $(BUILTIN_SRCDIR)/"$$hf" $(DESTDIR)$(headersdir)/builtins/$$hf; \ + ${INSTALL_DATA} $(BUILTIN_SRCDIR)/"$$hf" $(DESTDIR)$(headersdir)/builtins/$$hf || exit 1; \ done @for hf in $(CREATED_HEADERS) ; do \ - ${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \ + ${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \ done -$(INSTALL_DATA) $(SDIR)/bash.pc $(DESTDIR)$(pkgconfigdir)/bash.pc diff --git a/aclocal.m4 b/aclocal.m4 index a29d26de..ba2446e3 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -2230,7 +2230,12 @@ AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset AC_DEFUN([BASH_FUNC_SBRK], [ - AC_CHECK_FUNCS_ONCE([sbrk]) + AC_MSG_CHECKING([for sbrk]) + AC_CACHE_VAL(ac_cv_func_sbrk, + [AC_TRY_LINK([#include ], + [ void *x = sbrk (4096); ], + ac_cv_func_sbrk=yes, ac_cv_func_sbrk=no)]) + AC_MSG_RESULT($ac_cv_func_sbrk) if test X$ac_cv_func_sbrk = Xyes; then AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk], [AC_TRY_RUN([ @@ -2253,8 +2258,8 @@ main(int c, char **v) ac_cv_func_sbrk=no fi fi - if test $ac_cv_func_sbrk = no; then - AC_DEFINE(HAVE_SBRK, 0, + if test $ac_cv_func_sbrk = yes; then + AC_DEFINE(HAVE_SBRK, 1, [Define if you have a working sbrk function.]) fi ]) diff --git a/configure b/configure index 53694fc9..9890529d 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Bash 5.1, version 5.020. +# From configure.ac for Bash 5.1, version 5.021. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for bash 5.1-alpha. # @@ -2691,7 +2691,6 @@ as_fn_append ac_func_list " uselocale" as_fn_append ac_header_list " xlocale.h" as_fn_append ac_header_list " sys/time.h" as_fn_append ac_func_list " alarm" -as_fn_append ac_func_list " sbrk" as_fn_append ac_func_list " fpurge" as_fn_append ac_func_list " __fpurge" as_fn_append ac_func_list " snprintf" @@ -2903,6 +2902,9 @@ m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF *-aix*) opt_bash_malloc=no ;; # AIX machines *-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment +# These lack a working sbrk(2) +aarch64-freebsd*) opt_bash_malloc=no ;; +riscv*-freebsd*) opt_bash_malloc=no ;; # Mach-derived systems have a ton of extra malloc functions and lack sbrk(2) *-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep *-openstep*) opt_bash_malloc=no ;; # i386/Sparc/HP machines running Openstep @@ -18541,9 +18543,33 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sbrk" >&5 +$as_echo_n "checking for sbrk... " >&6; } + if ${ac_cv_func_sbrk+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + void *x = sbrk (4096); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_sbrk=yes +else + ac_cv_func_sbrk=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi - - + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_sbrk" >&5 +$as_echo "$ac_cv_func_sbrk" >&6; } if test X$ac_cv_func_sbrk = Xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working sbrk" >&5 $as_echo_n "checking for working sbrk... " >&6; } @@ -18588,9 +18614,9 @@ $as_echo "$bash_cv_func_sbrk" >&6; } ac_cv_func_sbrk=no fi fi - if test $ac_cv_func_sbrk = no; then + if test $ac_cv_func_sbrk = yes; then -$as_echo "#define HAVE_SBRK 0" >>confdefs.h +$as_echo "#define HAVE_SBRK 1" >>confdefs.h fi diff --git a/configure.ac b/configure.ac index 73a236b9..f5793e7a 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script. # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AC_REVISION([for Bash 5.1, version 5.020])dnl +AC_REVISION([for Bash 5.1, version 5.021])dnl define(bashvers, 5.1) define(relstatus, alpha) @@ -77,6 +77,9 @@ m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF *-aix*) opt_bash_malloc=no ;; # AIX machines *-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment +# These lack a working sbrk(2) +aarch64-freebsd*) opt_bash_malloc=no ;; +riscv*-freebsd*) opt_bash_malloc=no ;; # Mach-derived systems have a ton of extra malloc functions and lack sbrk(2) *-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep *-openstep*) opt_bash_malloc=no ;; # i386/Sparc/HP machines running Openstep diff --git a/doc/bashref.texi b/doc/bashref.texi index 57ccdf06..462116c2 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -5529,12 +5529,6 @@ If set, the @code{echo} builtin expands backslash-escape sequences by default. @end table - -@noindent -The return status when listing options is zero if all @var{optnames} -are enabled, non-zero otherwise. -When setting or unsetting options, the return status is zero unless an -@var{optname} is not a valid shell option. @end table @node Special Builtins diff --git a/examples/loadables/finfo.c b/examples/loadables/finfo.c index 72f859f6..8c278c35 100644 --- a/examples/loadables/finfo.c +++ b/examples/loadables/finfo.c @@ -340,13 +340,13 @@ int flags; else printf("%ld\n", st->st_ctime); } else if (flags & OPT_DEV) - printf("%d\n", st->st_dev); + printf("%lu\n", (unsigned long)st->st_dev); else if (flags & OPT_INO) printf("%lu\n", (unsigned long)st->st_ino); else if (flags & OPT_FID) - printf("%d:%lu\n", st->st_dev, (unsigned long)st->st_ino); + printf("%lu:%lu\n", (unsigned long)st->st_dev, (unsigned long)st->st_ino); else if (flags & OPT_NLINK) - printf("%d\n", st->st_nlink); + printf("%lu\n", (unsigned long)st->st_nlink); else if (flags & OPT_LNKNAM) { #ifdef S_ISLNK b = xmalloc(4096); diff --git a/unwind_prot.c b/unwind_prot.c index 664e3a9b..ef831d81 100644 --- a/unwind_prot.c +++ b/unwind_prot.c @@ -349,6 +349,8 @@ unwind_protect_mem_internal (var, psize) size = *(int *) psize; allocated = size + offsetof (UNWIND_ELT, sv.v.desired_setting[0]); + if (allocated < sizeof (UNWIND_ELT)) + allocated = sizeof (UNWIND_ELT); elt = (UNWIND_ELT *)xmalloc (allocated); elt->head.next = unwind_protect_list; elt->head.cleanup = (Function *) restore_variable; diff --git a/xmalloc.c b/xmalloc.c index ca297dcf..1b3b4088 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -47,11 +47,11 @@ # endif /* !__STDC__ */ #endif /* !PTR_T */ -#if defined (HAVE_SBRK) && !HAVE_DECL_SBRK +#if HAVE_SBRK && !HAVE_DECL_SBRK extern char *sbrk(); #endif -#if defined (HAVE_SBRK) && defined (USING_BASH_MALLOC) +#if HAVE_SBRK && defined (USING_BASH_MALLOC) static PTR_T lbreak; static int brkfound; static size_t allocated; @@ -63,7 +63,7 @@ static size_t allocated; /* */ /* **************************************************************** */ -#if defined (HAVE_SBRK) && defined (USING_BASH_MALLOC) +#if HAVE_SBRK && defined (USING_BASH_MALLOC) #define FINDBRK() \ do { \ if (brkfound == 0) \ @@ -88,7 +88,7 @@ allocerr (func, bytes) const char *func; size_t bytes; { -#if defined (HAVE_SBRK) && defined (USING_BASH_MALLOC) +#if HAVE_SBRK && defined (USING_BASH_MALLOC) allocated = findbrk (); fatal_error (_("%s: cannot allocate %lu bytes (%lu bytes allocated)"), func, (unsigned long)bytes, (unsigned long)allocated); #else @@ -160,7 +160,7 @@ sh_allocerr (func, bytes, file, line) char *file; int line; { -#if defined (HAVE_SBRK) +#if HAVE_SBRK allocated = findbrk (); fatal_error (_("%s: %s:%d: cannot allocate %lu bytes (%lu bytes allocated)"), func, file, line, (unsigned long)bytes, (unsigned long)allocated); #else