Thread overview
[Issue 8742] New: Anonymous nested class derived from another nested class makes DMD crash
Oct 01, 2012
David Eckardt
Jan 10, 2013
Andrej Mitrovic
Jan 10, 2013
David Eckardt
Jan 11, 2013
Kenji Hara
Jan 11, 2013
Andrej Mitrovic
Jan 14, 2013
Walter Bright
October 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8742

           Summary: Anonymous nested class derived from another nested
                    class makes DMD crash
           Product: D
           Version: D1 & D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: david.eckardt@sociomantic.com


--- Comment #0 from David Eckardt <david.eckardt@sociomantic.com> 2012-10-01 06:29:21 PDT ---
When compiling the following example module, DMD 1.075 or 2.060 crashes with Segmentation Fault with -version=Crash; it does not without.

---
module crash;

class C
{
    class D { }
}

void main ( )
{
    auto c = new C;

    version(Crash) auto d = c.new class C.D { };
}
---

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


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-10 07:30:02 PST ---
Is this valid code to begin with?

@Kenji @Walter: `toParent2()->getType()` returns NULL, hence isBaseOf crashes
when it tries to call `t->ty` on a NULL `t`. I can add a check to `isBaseOf`,
then it will return:

test.d(11): Error: class test.main.__anonclass1 is nested within main, but
super class D is nested within C
test.d(11): Error: e.new is only for allocating nested classes

So it would turn the ICE into an error, but is that ok or is the code actually valid?

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



--- Comment #2 from David Eckardt <david.eckardt@sociomantic.com> 2013-01-10 10:43:28 PST ---
It sounds plausible to me that the code is invalid due to wrong nesting; I didn't notice that, sorry.

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



--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-01-11 00:12:02 PST ---
(In reply to comment #1)
> Is this valid code to begin with?
> 
> @Kenji @Walter: `toParent2()->getType()` returns NULL, hence isBaseOf crashes
> when it tries to call `t->ty` on a NULL `t`. I can add a check to `isBaseOf`,
> then it will return:
> 
> test.d(11): Error: class test.main.__anonclass1 is nested within main, but
> super class D is nested within C
> test.d(11): Error: e.new is only for allocating nested classes
> 
> So it would turn the ICE into an error, but is that ok or is the code actually valid?

Seems reasonable.
In the case, anonymous class typeof(d) requires two context pointers, one is of
'c', one another is of 'main'.  But it is disallowed.

So, the original code should be an error in my opinion.

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


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Platform|x86_64                      |All
         OS/Version|Linux                       |All


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-11 08:12:35 PST ---
https://github.com/D-Programming-Language/dmd/pull/1466

D2 only. But D1 is officially deprecated, so what happens next? Will walter merge it into D1? I'll bring the popcorn!

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



--- Comment #5 from github-bugzilla@puremagic.com 2013-01-13 17:08:08 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/2e20e68eae3473b514d7cfa0275afa704c6990df Fixes Issue 8742 - ICE on anon class derived from nested class.

https://github.com/D-Programming-Language/dmd/commit/c55d4ef45989574dddaa32f2e174bf5c5d0da90b Merge pull request #1466 from AndrejMitrovic/Fix8742

Issue 8742 - ICE on anon class derived from nested class.

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


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