> 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

Reply via email to