No thread safety in clock_gettime (hires_ns::prime)
Mon Nov 26 17:01:00 GMT 2018
On Nov 23 11:27, James E. King III wrote:
> Using 32-bit cygwin that I set up yesterday.
Don't do that. Use 64 bit Cygwin whenever possible. 32 bit is a lost
> I found that a call to
> clock_gettime(CLOCK_MONOTONIC, ..) has a one-time initialization that
> is not thread-safe. If two threads call this at the same time, they
> will race. The results I am seeing are typically that one of the two
> callers get a timespec structure with zero values, and no error return
> code from the call.
Thanks for the testcase, but I can't reproduce the problem, neither on
32 bit nor on 64 bit. I tweaked your makefile to have a 100K loop I
started multiple times with differently optimzed code, but to no avail.
To account for that, I inspected the code doing the initialization and
found that it uses REALTIME priority when trying to make sure multiple
threads don't collide. This is a bit on the dangerous side, apparently.
I tweaked the code to use a spinlock instead.
I'm just about to upload new developer snapshots to
Should be up in 10 mins or so. Can you please try if this fixes the
problem for you?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: not available
More information about the Cygwin