[PATCH 2/3] Fix `hashtest' target in Makefile
- Adds the dependency on the Bash's libmalloc - Removes the libintl dependency, since it's unused - Adds the `running_trap' global variable, since libmalloc depends on it when the `SHELL' macro is defined (see [1]) - Removes compiler warning due to missing return type in main function After these changes, the `hashtest' target can be built with: | dualbus@system76-pc:~/src/gnu/bash$ CC=gcc ./configure --silent --with-bash-malloc && make -j$(nproc) -s hashtest | | Beginning configuration for bash-5.0-rc1 for x86_64-pc-linux-gnu | | config.status: creating po/POTFILES | config.status: creating po/Makefile | ./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] | | *** | * * | * GNU bash, version 5.0.0(1)-rc1 (x86_64-pc-linux-gnu) | * * | *** | | make[1]: warning: -j16 forced in submake: resetting jobserver mode. | | dualbus@system76-pc:~/src/gnu/bash$ echo hi | ./hashtest >/dev/null 2>&1; echo $? | 0 It doesn't work if `--without-bash-malloc' is specified. [1] /usr/bin/ld: ./lib/malloc/libmalloc.a(malloc.o): in function `morecore': /home/dualbus/src/gnu/bash/lib/malloc/malloc.c:602: undefined reference to `running_trap' --- Makefile.in | 4 ++-- hashlib.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 5fcb44b0..76a51b19 100644 --- a/Makefile.in +++ b/Makefile.in @@ -967,8 +967,8 @@ depends: force $(Program) $(SUPPORT_SRC)mkdep -c ${CC} -- ${CCFLAGS} ${CSOURCES} PRIVATE TARGETS -hashtest: hashlib.c - $(CC) -DTEST_HASHING $(CCFLAGS) $(TEST_NBUCKETS) -o $@ $(srcdir)/hashlib.c xmalloc.o $(INTL_LIB) +hashtest: hashlib.c xmalloc.o $(MALLOC_LIBRARY) + $(CC) -DTEST_HASHING $(CCFLAGS) $(TEST_NBUCKETS) -o $@ $(srcdir)/hashlib.c xmalloc.o $(MALLOC_LIBRARY) DEPENDENCIES ### diff --git a/hashlib.c b/hashlib.c index 8adbe221..f8e3b09a 100644 --- a/hashlib.c +++ b/hashlib.c @@ -392,6 +392,7 @@ hash_pstats (table, name) HASH_TABLE *table, *ntable; int interrupt_immediately = 0; +int running_trap = 0; int signal_is_trapped (s) @@ -417,6 +418,7 @@ internal_warning (const char *format, ...) { } +int main () { char string[256]; -- 2.20.1
[PATCH 1/3] Fix implicit declaration of abort()
gcc version 8.2.0 (Debian 8.2.0-13) x86_64-linux-gnu ``` malloc.c:333:3: warning: incompatible implicit declaration of built-in function ‘abort’ malloc.c:333:3: note: include ‘’ or provide a declaration of ‘abort’ ``` --- lib/malloc/malloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c index 5621adf4..8f641036 100644 --- a/lib/malloc/malloc.c +++ b/lib/malloc/malloc.c @@ -83,6 +83,7 @@ #endif #include #include +#include #if defined (HAVE_MMAP) #include -- 2.20.1
[PATCH 3/3] Fix incompatible pointer type warning in unicode.c
The warning is raised by Clang (7.0.1-4) when sizeof(wchar_t) is 4 | dualbus@system76-pc:~/src/gnu/bash/lib/sh$ make unicode.o | clang -c -I. -I../.. -I../.. -I../../lib -I../../include -I. -DHAVE_CONFIG_H -DSHELL -ggdb -O0 -Wno-parentheses -Wno-format-security unicode.c | unicode.c:262:69: warning: incompatible pointer types passing 'wchar_t [3]' to parameter of type 'unsigned short *' [-Wincompatible-pointer-types] | else if (sizeof (wchar_t) == 2 && c <= 0x10 && u32toutf16 (c, ws)) | ^~ | 1 warning generated. dualbus@system76-pc:~/src/gnu/bash$ clang -v 2>&1 | head -n2 clang version 7.0.1-4 (tags/RELEASE_701/final) Target: x86_64-pc-linux-gnu In practice, this isn't really a problem because the compiler should optimize away the `sizeof(wchar_t) == 2' branch. Still, it's easy to fix. I think that maybe there should be some sort of compile-time assertion inside `u32toutf16`, to ensure it's only used when `sizeof(wchar_t) == 2', but I don't know how to do that. --- lib/sh/unicode.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sh/unicode.c b/lib/sh/unicode.c index fe13c4a0..99c422ab 100644 --- a/lib/sh/unicode.c +++ b/lib/sh/unicode.c @@ -216,21 +216,21 @@ u32toutf8 (wc, s) int u32toutf16 (c, s) u_bits32_t c; - unsigned short *s; + wchar_t *s; { int l; l = 0; if (c < 0x0d800 || (c >= 0x0e000 && c <= 0x0)) { - s[0] = (unsigned short) (c & 0x); + s[0] = (wchar_t) (c & 0x); l = 1; } else if (c >= 0x1 && c <= 0x010) { c -= 0x01; - s[0] = (unsigned short)((c >> 10) + 0xd800); - s[1] = (unsigned short)((c & 0x3ff) + 0xdc00); + s[0] = (wchar_t)((c >> 10) + 0xd800); + s[1] = (wchar_t)((c & 0x3ff) + 0xdc00); l = 2; } s[l] = 0; -- 2.20.1
Re: FIFO race condition on SunOS kernels
For the record, my colleague found the issue. There is bug in libc, race condition between signal and popen. Thank you for the report -- Vlad