Opened 9 years ago

Closed 9 years ago

#720 closed defect (fixed)

rng-mt failure

Reported by: Peter Owned by: Peter
Priority: minor Milestone: yat 0.9
Component: random Version: trunk
Keywords: Cc:

Description

Occasionally I get this output:

test1
x: 41 99 72 93 0 12 30 99 14 23 
y: 41 99 72 93 0 12 30 99 14 23 
x and y are equal
test2
x: 41 99 72 93 0 12 30 99 14 23 
y: 41 99 72 93 0 12 30 99 14 23 
ok
test3
x: 41 99 72 93 0 12 30 99 14 23 
y: 43 18 2 93 54 94 43 48 42 32 
ok
Test failed.

It happens about 1/3 or 1/4 of all times, which suggests that is some kind of race condition - either in the test or in RNG class.

Change History (2)

comment:1 Changed 9 years ago by Peter

Owner: changed from Jari Häkkinen to Peter
Status: newassigned

Problem is that rng_alloc is not thread safe. It modifies RNG::seed_ which is a global variable since RNG is a singleton. Other functions with same problem are RNG::seed(1) and RNG::seed_from_devurandom (since the latter calls the former). I guess we have to lock access to seed_, which should be OK. The cost in time is not important since rng_alloc is only called once for each tread.

comment:2 Changed 9 years ago by Peter

Resolution: fixed
Status: assignedclosed

(In [2833]) fixes #720

Note: See TracTickets for help on using tickets.