Boost logo

Boost Users :

Subject: [Boost-users] Segmentation fault in lagged fibonacci random number generator
From: Moritz Beber (moritz.beber_at_[hidden])
Date: 2010-07-20 15:08:30

Dear boost users,

I have a very strange segmentation fault in lagged fibonacci and
unfortunately, I was not able to reduce the problem to a simple example
yet. I know that stinks of the problem coming from my code but please
bear with me for a moment.

I have two classes that both use the same other class for some random
number generation. The two classes differ only in one unrelated
function. If I run my program with one class everything works just fine,
if I run it with the other after a few iterations the error occurs. I
have no idea why, since they both use the exact same class from which
the error occurs.

I use the following code to get my generators:

typedef boost::uniform_smallint<short unsigned> Small;
typedef boost::variate_generator<rfn::RandGen&, Small> Small_Number;

Small* _us_dist = new Small(1, 20);
Small_Number* _len_gen = new
Small_Number(rfn::Mutation::_parameters->rng(), *_us_dist);

Where rfn::Mutation::_parameters->rng() gives me a reference from a
lagged_fibonacci object held in that class.

I then try to get a number in the following way:

short unsigned length = (*_len_gen)();

I have attached a gdb run of the program crashing. If you have any
ideas where I can look for this error please tell me. It's also no
problem for me to send you the complete sources but it's a rather big

Thank you for your help,

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at