Thread overview
[Issue 9142] New: Segmentation fault (DMD only) when calling some external functions twice in one expression
Dec 11, 2012
Maksim Zholudev
Dec 11, 2012
Walter Bright
Dec 12, 2012
Maksim Zholudev
December 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9142

           Summary: Segmentation fault (DMD only) when calling some
                    external functions twice in one expression
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: maximzms@gmail.com


--- Comment #0 from Maksim Zholudev <maximzms@gmail.com> 2012-12-11 10:57:27 PST ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9142


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |WORKSFORME


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2012-12-11 14:19:23 PST ---
I cannot reproduce this with the current DMD.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9142


Maksim Zholudev <maximzms@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WORKSFORME                  |FIXED


--- Comment #2 from Maksim Zholudev <maximzms@gmail.com> 2012-12-12 00:44:25 PST ---
The latest version of DMD from GitHub works well. Thank you!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------