On Wed, Jul 22, 2020 at 06:38:42PM +0200, Theo Buehler wrote:
> > I don't know what's causing this. Is there some algorithm inside ksh
> > that could be running into complexity issues somehow?
> 
> Likely glob. Many glob implementations were found to suffer from
> complexity issues: https://research.swtch.com/glob
> 
> The glob(3) in libc was fixed
> https://github.com/openbsd/src/commit/5c36dd0c22429e7b00ed5df80ed1383807532b59
> but ksh's builtin glog still has the issue.
> 
> A quick ktrace seems to confirm that (I terminated the shell after it
> hung a while):
> 
>  58829 sh       5.883025 RET   getdents 1832/0x728
>  58829 sh       40.637429 PSIG  SIGTERM caught handler=0x64287f47850 mask=0<>
> 
> This likely points to the readdir call in globit() before globit() recurses:
> https://github.com/openbsd/src/blob/master/bin/ksh/eval.c#L1089-L1102

Well:

AC_LINK_IFELSE(
  [AC_LANG_PROGRAM([#include <stdio.h>], [
  return(0);
  ])],
  [CFLAGS_SANITIZE="$CFLAGS"], 
[CFLAGS_SANITIZE="****************ADDRESS_SANITIZER_NOT_SUPPORTED*********************"])

This works around the bug:

diff --git configure.ac configure.ac
index 0d22ad59b..f670bde1b 100644
--- configure.ac
+++ configure.ac
@@ -495,7 +495,7 @@ dnl check for sanitize build warnings support
 dnl ----------------------------
 AC_MSG_CHECKING([compiler/linker address santizer build warnings support])
 
-CFLAGS_SANITIZE_TRY="$CFLAGS_SANITIZE -W -Wall -Wno-unused-parameter 
-Wno-sign-compare -Wno-implicit-fallthrough -Wno-missing-field-initializers 
-Wno-shift-negative-value -Wno-old-style-declaration 
-Wno-unused-but-set-parameter"
+CFLAGS_SANITIZE_TRY="'$CFLAGS_SANITIZE' -W -Wall -Wno-unused-parameter 
-Wno-sign-compare -Wno-implicit-fallthrough -Wno-missing-field-initializers 
-Wno-shift-negative-value -Wno-old-style-declaration 
-Wno-unused-but-set-parameter"
 CFLAGS_SAVED="$CFLAGS"
 CFLAGS="$CFLAGS_SANITIZE_TRY"
 

Reply via email to