Jump to page: 1 2
Thread overview
[Issue 5064] New: Crash related to std.algorithm.map, delegates, and casts
Oct 16, 2010
klickverbot
Oct 16, 2010
klickverbot
Oct 16, 2010
klickverbot
[Issue 5064] std.algorithm.map, delegates and cast(dchar) = runtime crash
Nov 08, 2010
Don
Nov 23, 2010
Don
Feb 06, 2011
Brad Roberts
Apr 21, 2012
SomeDude
[Issue 5064] runtime crash using closure as alias parameter
May 21, 2012
Don
Jun 17, 2012
Denis Shelomovskij
Dec 27, 2012
Maxim Fomin
October 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5064

           Summary: Crash related to std.algorithm.map, delegates, and
                    casts
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@klickverbot.at


--- Comment #0 from klickverbot <code@klickverbot.at> 2010-10-16 13:29:55 PDT ---
The following program crashes using DMD 2.049 on Linux x86_64 and DMD 2.048 on OS X x86_64:

---
import std.algorithm;

void main() {
   foreach ( offset; 0 .. 26 ) {
      map!( ( c ){ return cast( dchar )offset; } )( "asdf" );
   }
}
---

If you remove the cast to dchar, the segmentation fault does no longer occur.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5064


klickverbot <code@klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code


--- Comment #1 from klickverbot <code@klickverbot.at> 2010-10-16 13:44:03 PDT ---
The foreach loop is not needed, another temporary »works« as well:

---
import std.algorithm;

void main() {
   auto a = 1;
   auto dg = ( uint c ){ return cast( dchar )a; };

   // This works:
   dg( 1 );

   // This crashes:
   map!( ( c ){ return dg( c ); } )( [ 1 ] );
}
---

GDB prints the innermost frame like this:
0x08049846 in ave.main.__dgliteral2!(int).__dgliteral2 (this=0x0, c=1) at
ave.d:11

Note that this is null – could this be an issue, or is this relative to the current frame?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5064



--- Comment #2 from klickverbot <code@klickverbot.at> 2010-10-16 13:58:43 PDT ---
The crash does not occur if the executable is compiled with -inline.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5064



--- Comment #3 from Don <clugdbug@yahoo.com.au> 2010-11-08 00:05:17 PST ---
Reduced test case. Possibly related to bug 1350.

struct Map(alias fun)
{
    dchar xxx;
    this(int[] input) {
       fun(input[0]);
    }
}

void main() {
   auto dg = ( int c ){ return cast(dchar)'x'; };

   Map!( ( c ){ return dg( c ); } )( [ 1 ] );
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 23, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5064



--- Comment #4 from Don <clugdbug@yahoo.com.au> 2010-11-23 01:25:27 PST ---
Further reduced. Shows it is caused by an closure passed as an alias parameter, + a struct with initialized members. If you remove the '=7', it won't crash.

----
struct Map5064(alias fun)
{
    int xxx = 7;
    void crash() {
       fun();
    }
}

void bug5064()
{
   void delegate() dg = (){ };

   Map5064!( dg ) q;
   q.crash();
}

void main()
{
    bug5064();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5064


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |andrei@metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5064


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|andrei@metalanguage.com     |bugzilla@digitalmars.com


--- Comment #5 from Andrei Alexandrescu <andrei@metalanguage.com> 2011-01-16 14:30:09 PST ---
Reassigning to Walter (Don, of course you're kindly invited to look into it); I thought this is a Phobos issue, but it's a dmd issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5064


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86_64                      |x86


--- Comment #6 from Brad Roberts <braddr@puremagic.com> 2011-02-06 15:41:02 PST ---
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.

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


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #7 from SomeDude <lovelydear@mailmetrash.com> 2012-04-21 15:58:29 PDT ---
I've noted that the issue is on x86_64, but FYI, on 2.059 Win32 the cases in description and comment 1 run fine (even without -inline), while Don's test cases produce an access violation.

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


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
         AssignedTo|bugzilla@digitalmars.com    |nobody@puremagic.com
            Summary|std.algorithm.map,          |runtime crash using closure
                   |delegates and cast(dchar) = |as alias parameter
                   |runtime crash               |
         OS/Version|Linux                       |All


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2