Boost logo

Boost Users :

Subject: Re: [Boost-users] 1.36.0 boost/random/uniform_01 Infinite[?] Loop
From: Dave Steenburgh (dave.steenburgh_at_[hidden])
Date: 2008-10-16 19:26:58


> Or better, a minimal example to try?
I'd like to think I know what the problem is now, but I'm still a little
mystified, and I'm not sure how best to correct it. What I think I want is
a correction to or replacement for my wrapper class, but I definitely want a
second opinion. (Maybe a third and a fourth, too...)

I've got a minimal-ish program that exhibits strange behavior, but it
doesn't get stuck. I suspect the same phenomenon is at work here, though,
since it still only appears when compiling without optimization. The source
is attached, and here are some of my observations: If I use ng instead of
vg, there is no problem. (Try it yourself; just move the comment slashes.)
 If I omit the call to problemFunction, everything works. If I decrease the
number of arguments problemFunction requires, everything works. Based on
that info, my guess is that something the random generator needs is created
on the stack, and later overwritten. However, I think if that were really
the problem, it would still be a problem on another platform, or with
optimizations enabled.

The printHistogram function is mostly unchanged from my original program,
and I kept it in this example because it makes the problem quite apparent.
 It prints data that can be used to create a histogram. Each line contains
two numbers; the first represents the minimum value of a histogram "bin,"
the second is a count of the values that fit in that bin. When everything
works correctly, the output should show a normal distribution. When this
problem manifests itself, the results always look a lot like this:

-1.30211,1
-1.27878,0
-1.25546,0
-1.23213,0
-1.2088,0
-1.18547,0
-1.16215,0
-1.13882,0
-1.11549,0
-1.09216,0
-1.06884,0
-1.04551,0
-1.02218,0
-0.998856,0
-0.975528,0
-0.952201,0
-0.928874,0
-0.905546,0
-0.882219,0
-0.858892,0
-0.835565,0
-0.812237,0
-0.78891,0
-0.765583,0
-0.742255,0
-0.718928,0
-0.695601,0
-0.672274,0
-0.648946,0
-0.625619,0
-0.602292,0
-0.578964,0
-0.555637,0
-0.53231,0
-0.508983,0
-0.485655,0
-0.462328,0
-0.439001,0
-0.415673,0
-0.392346,0
-0.369019,0
-0.345692,0
-0.322364,0
-0.299037,0
-0.27571,0
-0.252382,0
-0.229055,0
-0.205728,0
-0.182401,0
-0.159073,0
-0.135746,0
-0.112419,0
-0.0890915,0
-0.0657642,0
-0.0424369,499
-0.0191097,0
0.00421763,0
0.0275449,0
0.0508722,0
0.0741995,0
0.0975268,0
0.120854,0
0.144181,0
0.167509,0
0.190836,0
0.214163,0
0.23749,0
0.260818,0
0.284145,0
0.307472,0
0.3308,0
0.354127,0
0.377454,0
0.400781,0
0.424109,0
0.447436,0
0.470763,0
0.494091,499
0.517418,0
0.540745,0
0.564072,0
0.5874,0
0.610727,0
0.634054,0
0.657382,0
0.680709,0
0.704036,0
0.727363,0
0.750691,0
0.774018,0
0.797345,0
0.820673,0
0.844,0
0.867327,0
0.890654,0
0.913982,0
0.937309,0
0.960636,0
0.983964,0
1.00729,0
1.03062,1





Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net