This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Uninitialised rng state



Hi gsl-l,


Valgrind complains about using uninitialised memory when accessing all gsl_rng_size() bytes of the gsl_rng_state() arrays returned by some rng types.

One example is mt19937 whose state has lots of unsigned longs followed by an int. On a 64 bit machine the size of the state is 5000 bytes of which 4 bytes are pad bytes inserted by the compiler due to the mix of int/ulong. So later when I twiddle the state valgrind triggers on the uninitialised access. So I was wondering whether gsl_rng_alloc() really ought to calloc the state instead of mallocing it. Thoughts?

As a workaround I'm currently clearing the entire state right after calling gsl_rng_alloc() and then calling gsl_rng_set(rng, gsl_rng_default_seed) right after. This does quell valgrind, but is it a sane thing to do?

Cheers,

Joonas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]