Boost C++ Libraries: Ticket #4002: UUID documentation improvement https://svn.boost.org/trac10/ticket/4002 <p> I get "uninitialised value(s)" warnings in valgrind when I use the following code: </p> <p> boost::uuids::random_generator gen; boost::uuids::uuid u = gen(); if (u == u) <em> for valgrind's benefit </em></p> <blockquote> <p> whatever(); </p> </blockquote> <p> In the example, when I do not supply a random number generator to 'gen', it calls: </p> <blockquote> <p> detail::seed(*pURNG); </p> </blockquote> <p> Which does not initialise all its state variables (like rd_[]) before generating random numbers. </p> <p> I assume this is done to try and generate decent random numbers from uninitialised memory, especially when there is no /dev/urandom or similar available. That is ok, I suppose. </p> <p> However, it makes valgrind very noisy when comparing uuids and thus generates a lot of false-positives to sift through. </p> <p> It would be great if the documentation could talk a bit about this, and also suggest that you use a pattern like the following if the library-user wants to silence valgrind reports: </p> <p> boost::mt19937 ran; uuids::random_generator gen(ran); </p> <p> It would be nice if it could also tell the library user why this might not be such a good idea. (eg mt19937 doesn't seed the random values as randomly as uuid's seed_rnd.hpp, right?). </p> <p> Or perhaps you can surround the detail::seed() call with #ifdefs to allow the user to control when uninitialised memory is used for seeding (helpful to turn off when debugging). </p> <p> Thanks, Paul </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4002 Trac 1.4.3 Andy Tompkins Sat, 10 Apr 2010 15:20:09 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4002#comment:1 https://svn.boost.org/trac10/ticket/4002#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Added notes about valgrind and using the default constructor for boost::uuids::basic_random_generator. I would welcome a patch that suppress the errors as described in Valgrind's documentation (<a class="ext-link" href="http://valgrind.org/docs/manual/manual-core.html#manual-core.suppress"><span class="icon">​</span>http://valgrind.org/docs/manual/manual-core.html#manual-core.suppress</a>). </p> Ticket