Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 4 Apr 2013 17:48:50 -0700
From: Isaac Dunham <>
Subject: Re: Pending issues for next release

On Thu, 4 Apr 2013 19:37:42 -0400
Rich Felker <> wrote:

> > random_r (used by mesa?)
> Bleh, the API is pretty ugly. Thoughts on what we should do? Do they
> actually care about having a thread-local PRNG state, or are they only
> using it on the misguided idea that random might not be thread-safe?
The only place it happens is in src/glx/glxhash.c, which says this:
#ifndef __GLIBC__
#define HASH_RANDOM_DECL	char *ps, rs[256]
#define HASH_RANDOM_INIT(seed)	ps = initstate(seed, rs, sizeof(rs))
#define HASH_RANDOM		random()
#define HASH_RANDOM_DESTROY	setstate(ps)
#define HASH_RANDOM_DECL	struct random_data rd; int32_t rv; char rs[256]
#define HASH_RANDOM_INIT(seed)					\
   do {								\
      (void) memset(&rd, 0, sizeof(rd));			\
      (void) initstate_r(seed, rs, sizeof(rs), &rd);		\
   } while(0)
#define HASH_RANDOM             ((void) random_r(&rd, &rv), rv)

So mesa won't need it unless built for glibc.

This is the commit that made random_r conditional:
commit d09941c8cc2d4620eb774744c8878921b9dc3bcc
Author: Robert Noland <>
Date:   Tue Sep 22 11:49:57 2009 -0700

And the previous commit that made it an issue:

commit 9666529b5a5be1fcde82caadc2fe2efa5ea81e49
Author: Ian Romanick <>
Date:   Wed Sep 16 16:43:50 2009 -0700

    glx: Use initstate_r / random_r instead of corrupting global random number state
    Previously srandom and random were used.  This cause the global random
    number generator state to be modified.  This caused problems for
    applications that called srandom before calling into GLX.  By using
    local state the global state is left unmodified.
    This should fix bug #23774.

So that's the rationale: nothing to do with threads, just leave global state alone.
Isaac Dunham <>

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.