Bug 241491 - "ps -o lstart" broken for some locales
Summary: "ps -o lstart" broken for some locales
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.3-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
: 229453 230068 (view as bug list)
Depends on:
Reported: 2019-10-25 17:09 UTC by Mikhail Teterin
Modified: 2020-06-07 08:21 UTC (History)
3 users (show)

See Also:

Demonstrate the problem (172 bytes, text/plain)
2019-10-25 17:09 UTC, Mikhail Teterin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Teterin freebsd_committer 2019-10-25 17:09:18 UTC
Created attachment 208599 [details]
Demonstrate the problem

Depending on $LANG, the value printed for the STARTED column may be an empty string (or a sequence of blanks?)

Attached is a simple shell script listing both the broken and the Ok locales.
Comment 1 Mikhail Teterin freebsd_committer 2019-10-25 17:25:13 UTC
Looks like the UTF-8, US-ASCII, ISO8859-1 and ISO8859-15 are all fine, while most others (like my own uk_UA.KOI8-U) are broken...
Comment 2 Yuri Pankov freebsd_committer 2019-10-25 20:38:15 UTC
Apparently the problem isn't in ps itself and rather in libxo which talks about locales in general, but then uses a lot of handrolled conversions that apply only to ascii/utf-8. I'll look into it if no one beats me to it.
Comment 3 Yuri Pankov freebsd_committer 2019-10-25 22:06:47 UTC
It turned out to be not as bad as I thought, I'll try proposing a patch upstream:


Please check if it fixes the issue for you.
Comment 4 Yuri Pankov freebsd_committer 2020-06-07 08:01:04 UTC
*** Bug 229453 has been marked as a duplicate of this bug. ***
Comment 5 Yuri Pankov freebsd_committer 2020-06-07 08:01:45 UTC
*** Bug 230068 has been marked as a duplicate of this bug. ***
Comment 6 commit-hook freebsd_committer 2020-06-07 08:21:41 UTC
A commit references this bug:

Author: yuripv
Date: Sun Jun  7 08:21:20 UTC 2020
New revision: 361887
URL: https://svnweb.freebsd.org/changeset/base/361887

  ps: use %hs instead of %s format specifiers

  Use %hs (locale-based encoding) instead of %s (UTF-8) format for
  strings that are expected to be in current locale encoding (date/time,
  process names/argument list).

  PR:		241491
  Reviewed by:	phil
  Differential Revision:	https://reviews.freebsd.org/D22160