On Thu, 27 Sep 2012, Alexey Suslikov wrote:
> Removing only local variables part reverts us to previous behavior (i.e. 
> crashes).

My guess is your program is calling srandom(), srandomdev(), initstate() 
or setstate() as well.  Your diff doesn't protect the alteration of state, 
end_ptr, fptr, and rptr on those paths, so a call to initstate() while 
another thread is in random() can walk fptr and/or rptr out of the state 
array.  Add the necessary locking in them and run your tests again.

If not, well, crank up your debugging skills.  What was the line of code 
that actually triggered the crash?  Where did the bogus pointer come from?


> I'm starting to believe that static globals are not good.

They are incredibly good at what they do.  If you're trying to say that 
they fundamentally can't be thread-safe, you'll need some extraordinary 
evidence for such a claim.


Philip Guenther

Reply via email to