Opened 13 years ago

Closed 13 years ago

#4002 closed Bugs (fixed)

UUID documentation improvement

Reported by: harris.pc@… Owned by: Andy Tompkins
Milestone: Boost 1.43.0 Component: uuid
Version: Boost 1.42.0 Severity: Optimization
Keywords: Cc:

Description

I get "uninitialised value(s)" warnings in valgrind when I use the following code:

boost::uuids::random_generator gen; boost::uuids::uuid u = gen(); if (u == u) for valgrind's benefit

whatever();

In the example, when I do not supply a random number generator to 'gen', it calls:

detail::seed(*pURNG);

Which does not initialise all its state variables (like rd_[]) before generating random numbers.

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.

However, it makes valgrind very noisy when comparing uuids and thus generates a lot of false-positives to sift through.

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:

boost::mt19937 ran; uuids::random_generator gen(ran);

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?).

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).

Thanks, Paul

Change History (1)

comment:1 by Andy Tompkins, 13 years ago

Resolution: fixed
Status: newclosed

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 (http://valgrind.org/docs/manual/manual-core.html#manual-core.suppress).

Note: See TracTickets for help on using tickets.