mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: detect timezone changes by monitoring /etc/localtime (like glibc)
Date: Fri, 9 Jun 2017 08:15:02 -0400	[thread overview]
Message-ID: <20170609121502.GO1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <488f8d57-555b-9328-f768-5779ea8aa8ec@gmail.com>

On Fri, Jun 09, 2017 at 05:15:40PM +1000, Patrick Oppenlander wrote:
> During some recent testing I came across a bug when adjusting timezones on an
> embedded system by changing /etc/localtime. The cause ended up being a
> behavioural difference between glibc and musl.

This difference is intentional; I believe there are past discussions
in the list archives.

Aside from the glibc behavior giving abysmal performance (syscalls on
every time operation), there's a more fundamental issue of usability
of the results. A common important idiom with time functions is to
perform several operations together in succession to get a result --
for example, obtain the current time as time_t, format it with
localtime[_r], make some adjustment e.g. for a relative time, then
call mktime to convert back to time_t. Such operations rely on the
time zone being consistent for each suboperation, which is true as
long as the application does not modify its own environment, but only
assuming libc doesn't impose asynchronous changes on the timezone.

In order for asynchronous timezone changes to be safe, the API would
have to be such that you make one call to get the current timezone,
then pass it as an argument to functions depending on the timezone, so
that the application has control of which timezone is getting used in
each call.

Rich


  reply	other threads:[~2017-06-09 12:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09  7:15 Patrick Oppenlander
2017-06-09 12:15 ` Rich Felker [this message]
2017-06-10  3:36   ` A. Wilcox
2017-06-10  9:57     ` u-uy74
2017-06-10 12:23       ` Rich Felker
2017-06-10 13:23         ` u-uy74
2017-06-12 23:08   ` Patrick Oppenlander
2017-06-12 23:19     ` Rich Felker
2017-06-12 23:49       ` Patrick Oppenlander
2017-06-12 23:58         ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170609121502.GO1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).