[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] Bus Error caused by gsl_rng_uniform()
From: |
Mike Fuller |
Subject: |
[Help-gsl] Bus Error caused by gsl_rng_uniform() |
Date: |
Thu, 6 Jan 2005 15:37:03 -0500 |
Is there a known memory allocation problem with gsl_rng_uniform()? I
get a Bus Error at runtime when using the gsl uniform random number
generator gsl_rng_uniform() in C++ code. The error does not occur when
I use the gsl Gaussian random number generator gsl_ran_gaussian().
(See the gdb error message, below the code.)
Here is the offending code (it's called gsl_test.cpp):
#include <iostream>
#include <cstdlib>
#include <gsl/gsl_rng.h>
using namespace std;
int main()
{
const gsl_rng_type* T;
gsl_rng* r;
int i, n = 10;
double u;
gsl_rng_env_setup();
T = gsl_rng_default;
r - gsl_rng_alloc(T);
for(i = 0; i < n; i++) {
u = gsl_rng_uniform(r);
std::cout << u << std::endl;
}
gsl_rng_free(r);
return 0;
}
The debugging program gdb gives the following error message:
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x000028ec in gsl_rng_uniform () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
76 // For construction of filebuffers for cout, cin, cerr, clog
et. al.
(gdb) bt
#0 0x000028ec in gsl_rng_uniform () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
#1 0x00002518 in main () at gsl_test.cpp:19
Note: bt (backtrace) confirms that gsl_rng_uniform is the source of the
problem. I thought the error message suggests the problem might involve
iostream, but the error only crops up when the call to
gsl_rng_uniform() is included and does not go away when I comment out
the line that uses cout.
The source was compiled on a G4 iBook with OS 10.3.7 (gcc 3.3). Here
is the compile command:
g++ -g -o gsl_test gsl_test.cpp -lgsl
Again, when I compile similar code that uses gsl_ran_gaussian() instead
of gsl_rng_uniform(), it compiles and runs correctly. Any ideas why
gsl_rng_uniform() is causing this bus error?
Thanks,
Mike
- [Help-gsl] Bus Error caused by gsl_rng_uniform(),
Mike Fuller <=