www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9142] New: Segmentation fault (DMD only) when calling some external functions twice in one expression

reply d-bugmail puremagic.com writes:
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



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: -------
Dec 11 2012
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Dec 11 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9142


Maksim Zholudev <maximzms gmail.com> changed:

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



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: -------
Dec 12 2012