Comment #0 by stephan.schiffels — 2012-05-26T14:29:20Z
The following program tries to trivially run a function from the GSL. It compiles, but generates a segmentation fault when run.
gsltest.d
--------------------------
import std.stdio;
extern (C) double gsl_sf_hyperg_2F1(double a, double b, double c,
double x);
void main() {
double f = 0.0025;
auto ret = f * gsl_sf_hyperg_2F1(1.0, 10.0, 11.0, 1.0 - f /
0.025);
writeln(ret);
}
---------------------------
The program should return 0.015681, which is the
numerically correct result. Note that the bug can not be in the GSL itself, as it works correctly when used with C or C++.
To compile and run the code, I used the following command line:
rdmd -L-L/opt/local/lib -L-lgsl -L-lgslcblas gsltest.d
(assuming that gel libraries are in /opt/local/lib)
This seems to be a bug related to how C library functions are called from D.
Stephan
Comment #1 by stephan.schiffels — 2012-05-26T16:56:44Z
I ran the executable through the GNU debugger. Here is the output:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x00007fff912a86cd in misaligned_stack_error_entering_dyld_stub_binder ()
And most peculiar by the way: If I drop the variable f, but simply put 0.025 directly in front of the function, the program does NOT crash...
Comment #2 by clugdbug — 2012-05-31T05:15:17Z
Related to bug 5570?
Comment #3 by stephan.schiffels — 2012-07-03T15:35:36Z
(In reply to comment #2)
> Related to bug 5570?
That may well be. I am unable to check how things compare between 32 and 64 bits, though.
Stephan
Comment #4 by stephan.schiffels — 2013-01-22T14:10:40Z
This issue is resolved. Tested on dmd 2.061.
Thanks for fixing!
Stephan