www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18714] New: Phobos calls localtime, which is not threadsafe

https://issues.dlang.org/show_bug.cgi?id=18714

          Issue ID: 18714
           Summary: Phobos calls localtime, which is not threadsafe
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

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.

--
Apr 03 2018