On Thu, 27 Sep 2012, Alexey Suslikov wrote: > On Thursday, September 27, 2012, Alexey Suslikov wrote: > > On Thursday, September 27, 2012, Philip Guenther wrote: > >> 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.
Have you done this? You based your patch on changes made to some other BSD (NetBSD, IIRC): have you put in place all the locking calls that they did? If not, why are wasting everyone's time by ignoring their work? > >> > 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. > >> > > What good they do? Static globals provide low overhead shared storage that doesn't pollute the global namespace. > Philip, can you help us to write threaded test case (spawning a number > of threads each calling random)? Sorry, this isn't near the top of my TODO list, and I've already made my suggestions on what you should be trying. Philip Guenther