# HG changeset patch # User Adam Chlipala # Date 1386806082 18000 # Node ID 8e6e3d9cea228dd30315bee5338b7b23fdac6c64 # Parent 98895243b5b6d3633ceba48eabd4c90e4327c07e RAND_bytes isn't thread-safe, so wrap it with a lock diff -r 98895243b5b6 -r 8e6e3d9cea22 src/c/urweb.c --- a/src/c/urweb.c Wed Dec 11 18:22:10 2013 -0500 +++ b/src/c/urweb.c Wed Dec 11 18:54:42 2013 -0500 @@ -4023,9 +4023,13 @@ return uw_unit_v; } +static pthread_mutex_t rand_mutex = PTHREAD_MUTEX_INITIALIZER; + uw_Basis_int uw_Basis_rand(uw_context ctx) { uw_Basis_int ret; + pthread_mutex_lock(&rand_mutex); int r = RAND_bytes((unsigned char *)&ret, sizeof ret); + pthread_mutex_unlock(&rand_mutex); if (r) return abs(ret);