Bug 18714 – Phobos calls localtime, which is not threadsafe
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-04-03T07:50:15Z
Last change time
2018-04-04T07:29:45Z
Assigned to
No Owner
Creator
FeepingCreature
Comments
Comment #0 by default_357-line — 2018-04-03T07:50:15Z
To implement timezone handling, std.datetime.timezone calls localtime. localtime returns a pointer to a global shared struct. This means that subsequent calls to localtime in a second thread may overwrite the data of the first thread before the first thread can read it, causing corruption. This can be seen by calling localtime on two different arguments in a loop, in two threads, and validating the result.
Comment #1 by github-bugzilla — 2018-04-03T09:22:01Z