Project

General

Profile

Bug #6520

ksh: sleep could wait forever

Added by Marcel Telka almost 5 years ago. Updated 3 months ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
locale - data and messages
Start date:
2015-12-18
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

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

Related to illumos gate - Bug #1239: sleep should not be locale sensitiveResolvedRobert Mustacchi2011-07-22

Actions
Related to illumos gate - Feature #11876: Want a native sleepClosedRobert Mustacchi

Actions
Related to illumos gate - Bug #12069: Backport sh_delay() and tvsleep() from ksh-2020.0.0Closed

Actions
#1

Updated by Marcel Telka about 1 year ago

  • Related to Bug #1239: sleep should not be locale sensitive added
#2

Updated by Robert Mustacchi about 1 year ago

  • Assignee set to Robert Mustacchi
#3

Updated by Robert Mustacchi about 1 year ago

#4

Updated by Marcel Telka 12 months ago

  • Related to Bug #12069: Backport sh_delay() and tvsleep() from ksh-2020.0.0 added
#5

Updated by Robert Mustacchi 11 months ago

  • Status changed from New to Resolved

Between both 11876 and 12069, I believe this can be put to rest.

#6

Updated by Marcel Telka 11 months 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" &
$
#7

Updated by Robert Mustacchi 11 months 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.

#8

Updated by Marcel Telka 11 months 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 :-).

#9

Updated by Robert Mustacchi 3 months ago

  • Assignee deleted (Robert Mustacchi)

Also available in: Atom PDF