Bug 9142 – Segmentation fault (DMD only) when calling some external functions twice in one expression
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-12-11T10:57:00Z
Last change time
2012-12-12T00:44:25Z
Assigned to
nobody
Creator
maximzms
Comments
Comment #0 by maximzms — 2012-12-11T10:57:27Z
When I call some GSL functions from a D program this causes segmentation fault.
This happens:
at least with gsl_sf_sin and gsl_sf_cos;
only if compiled with DMD (no error with GDC);
only if the functions a called twice in the same arithmetic expression;
not for all argument values (1e-4 is OK, 2e-4 is not).
Order of operands matters if "bad" and "good" argument values are combined in the same expression.
Wrapping of functions does not help.
Code:
----------
import std.stdio;
extern(C) double gsl_sf_sin(double x);
void main()
{
writeln(gsl_sf_sin(2e-4) + gsl_sf_sin(1e-4));
double a = gsl_sf_sin(1e-4);
writeln(a + gsl_sf_sin(2e-4));
writeln(gsl_sf_sin(1e-4) + gsl_sf_sin(2e-4)); //ERROR
}
----------
With DMD v2.060:
dmd test.d -L-lgsl -L-lblas
0.0003
0.0003
Segmentation fault
With GDC-4.6:
gdc-4.6 test.d -lgsl -lblas
0.0003
0.0003
0.0003
Comment #1 by bugzilla — 2012-12-11T14:19:23Z
I cannot reproduce this with the current DMD.
Comment #2 by maximzms — 2012-12-12T00:44:25Z
The latest version of DMD from GitHub works well. Thank you!