www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2766] New: DMD hangs with 0%cpu

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2766

           Summary: DMD hangs with 0%cpu
           Product: D
           Version: 2.026
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: benoit tionex.de


compile with "dmd -c t.d"
const byte[] A = [ cast(byte)0 ];
void f( byte* p){
}
void func(){
    f(A.ptr);
}


-- 
Mar 27 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2766





------- Comment #1 from unknown simplemachines.org  2009-03-29 04:50 -------
Created an attachment (id=299)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=299&action=view)
Potential fix - prevent recursion if optimized type matches.

I'm not sure this is the right solution, but this does solve this problem.

The stack is overflowing (eventually), for some reason this is causing a hang. 
It's caused by keyword #1, |const|.  It's trying to cast from const(byte[]) to
byte*.

This seems like something one might see a lot, actually.

What's happening is, |Expression::implicitConvTo()| gets called being
|cast(const(byte)*)cast(const(byte)*)[cast(byte)0]|.  The optimize() call
strips off one of those casts and returns a new |e|, so it calls itself on the
optimized one.  But somehow, that mangy cast gets back in there, and it
recurses endlessly like this.

Visual Studio doesn't show any calls between calls to
|Expression::implicitConvTo()|, but I'm not seeing where it is changing. 
Nonetheless, |e| and |this| are different each time.

However, the purpose of this recursion seems to simply be to properly check the
optimized type.  If the optimizer didn't change this type, it hardly seems
necessary to recurse.  This also happens in |Expression::implicitCastTo()|.

Still, there is a deeper problem where the cast is doubling up.  This works
around the issue (hopefully not incorrectly), but does not solve the root
issue.

-[Unknown]


-- 
Mar 29 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2766





------- Comment #2 from bugzilla digitalmars.com  2009-03-29 16:17 -------
I've got it fixed, so don't worry about it further. -Walter


-- 
Mar 29 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2766


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #3 from bugzilla digitalmars.com  2009-04-01 13:58 -------
Fixed DMD 2.027


-- 
Apr 01 2009