Opened 11 years ago
Closed 11 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 11 years ago by
Owner: | changed from Jari Häkkinen to Peter |
---|---|
Status: | new → assigned |
comment:2 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note: See
TracTickets for help on using
tickets.
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)
andRNG::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 sincerng_alloc
is only called once for each tread.