Bug #6520
closedksh: sleep could wait forever
100%
Description
The following hangs forever:
$ LC_NUMERIC=sk_SK.UTF-8 /usr/bin/ksh "sleep .2"
The problem is that poll() is called with negative timeout, so it is ignored and pollsys() waits forever:
$ pstack $(pgrep -x ksh) 29022: /usr/bin/ksh sleep .2 fffffd7fff2ce0ba pollsys (fffffd7fffdff2a0, 0, 0, 0) fffffd7fff25fee6 poll (fffffd7fffdff2a0, 0, 80000000) + 56 fffffd7fff0db041 sh_delay () + 61 fffffd7fff0dac64 b_sleep (2, 41b8a0, fffffd7fff172830) + 1b4 fffffd7fff13c2b9 sh_exec (41b820, 25) + 44e9 fffffd7fff113868 exfile (fffffd7fff172380, 4291f0, ffffffff) + 7a8 fffffd7fff112a1c sh_main (2, fffffd7fffdff978, 0) + 36c 0000000000400f95 main () + 55 0000000000400e3c _start () + 6c $
It looks like it is reproducible using any locale where comma is used as a decimal point (for example these locales are affected too: cs_CZ.UTF-8, de_DE.UTF-8, fr_FR.UTF-8, es_ES.UTF-8, pt_BR.UTF-8).
You could check your decimal point definition using the locale(1):
$ locale decimal_point , $
Workaround
Use any locale with "." as decimal point, like en_US.UTF-8.
Related issues
Updated by Marcel Telka over 3 years ago
- Related to Bug #1239: sleep should not be locale sensitive added
Updated by Robert Mustacchi over 3 years ago
- Related to Feature #11876: Want a native sleep added
Updated by Marcel Telka over 3 years ago
- Related to Bug #12069: Backport sh_delay() and tvsleep() from ksh-2020.0.0 added
Updated by Robert Mustacchi over 3 years ago
- Status changed from New to Resolved
Between both 11876 and 12069, I believe this can be put to rest.
Updated by Marcel Telka over 3 years ago
- Status changed from Resolved to In Progress
Robert Mustacchi wrote:
Between both 11876 and 12069, I believe this can be put to rest.
Sorry, no. Neither #11876 nor #12069 fixed this bug:
$ uname -v illumos-9554f7e18d $ ls -l /usr/bin/sleep -r-xr-xr-x 1 root bin 13352 Jan 14 22:00 /usr/bin/sleep $ LC_NUMERIC=sk_SK.UTF-8 /usr/bin/ksh "sleep .2" & [1] 10376 $ sleep 10 $ jobs [1]+ Running LC_NUMERIC=sk_SK.UTF-8 /usr/bin/ksh "sleep .2" & $
Updated by Robert Mustacchi over 3 years ago
Sorry, yes, this didn't actually fix the ksh specific part of it, only the /usr/bin/sleep bit. I mistakenly combined that with the actual ksh sleep portion.
Updated by Marcel Telka over 3 years ago
The only difference is that after #12069 sleep waits forever with this stack instead:
$ pstack 10376 10376: /usr/bin/ksh sleep .2 fffffd7feee895aa nanosleep (fffffd7fffdf46e0, fffffd7fffdf46f0) fffffd7feeba4ec5 tvsleep (fffffd7fffdf4740, fffffd7fffdf4748) + 35 fffffd7fef1fd80e sh_delay () + 6e fffffd7fef1fd403 b_sleep (2, 8bc5d0, fffffd7fef2947d0) + 173 fffffd7fef25d509 sh_exec (8bc550, 25) + 38c9 fffffd7fef235b9e exfile (fffffd7fef294320, 8c4c20, ffffffff) + a1e fffffd7fef234b8b sh_main (2, fffffd7fffdf52c8, 0) + 3cb 000000000040146d main () + 4d 0000000000401333 _start_crt () + 83 0000000000401298 _start () + 18 $
And the problem seems to be this:
$ mdb -p 10376 -e fffffd7fffdf46e0/E 0xfffffd7fffdf46e0: 2678400 $
So it looks like it is not forever, just 31 days :-).
Updated by Robert Mustacchi over 2 years ago
- Assignee deleted (
Robert Mustacchi)
Updated by Andy Fiddaman over 2 years ago
This is resolved in the newer ksh being integrated under #13405
af@bloody:~/ksh$ echo $KSH_VERSION Version jMP 93u+ 2012-08-01 af@bloody:~/ksh$ locale decimal_point , af@bloody:~/ksh$ sleep .2 sleep: .2: bad number af@bloody:~/ksh$ sleep ,2 af@bloody:~/ksh$
Updated by Electric Monk over 2 years ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
git commit b30d193948be5a7794d7ae3ba0ed9c2f72c88e0f
commit b30d193948be5a7794d7ae3ba0ed9c2f72c88e0f Author: Andy Fiddaman <omnios@citrus-it.co.uk> Date: 2021-01-30T17:13:33.000Z 13405 ksh93 update to 2012-08-01 13434 sh: mishandles backslash as last character of a block of input 11750 ksh mkdir builtin doesn't honor special file permissions 9199 ksh93 builtin *grep -v mishandles blank lines, blows up libgcrypt-config 6756 sh (and ksh) have issues with ${1+"$@"} 6520 ksh: sleep could wait forever 4860 ksh93: core in printf 3791 /bin/sh's builtin 'rm' busted: 'rm -f' without arguments returns error 1047 ksh overwrites child core files 880 ksh93 coredumps on 'unset' 499 "interrupted system call" when using "tee" builtin in ksh Reviewed by: Robert Mustacchi <rm@fingolfin.org> Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> Reviewed by: Dominik Hassler <hadfl@omnios.org> Approved by: Rich Lowe <richlowe@richlowe.net>