From: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
To: gsl-discuss@sources.redhat.com
Subject: Uninitialised rng state
Date: Sat, 07 Feb 2009 06:30:00 -0000 [thread overview]
Message-ID: <Pine.OSF.4.61.0902070815060.347812@sirppi.helsinki.fi> (raw)
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
next reply other threads:[~2009-02-07 6:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-07 6:30 M Joonas Pihlaja [this message]
2009-02-09 14:46 ` Brian Gough
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.OSF.4.61.0902070815060.347812@sirppi.helsinki.fi \
--to=jpihlaja@cc.helsinki.fi \
--cc=gsl-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).