Thread overview
[Issue 9540] New: Compiler crash on delegate context frame assignment
Feb 20, 2013
Carlos Santander
Feb 20, 2013
Carlos Santander
Feb 20, 2013
Maxim Fomin
Feb 20, 2013
Maxim Fomin
Feb 20, 2013
Maxim Fomin
Apr 14, 2013
Dmitry Olshansky
Apr 23, 2013
Kenji Hara
Apr 23, 2013
Kenji Hara
February 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9540

           Summary: Compiler crash on delegate context frame assignment
           Product: D
           Version: D2
          Platform: x86
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: csantander@outlook.com


--- Comment #0 from Carlos Santander <csantander@outlook.com> 2013-02-19 19:31:35 EST ---
I'm trying to write a particular template, and once I got to a certain point, I got DMD to crash. I'm attaching the file with the offending code. The compiler output is:

> Assertion failed: (0), function totym, file glue.c, line 1235.
> Abort trap: 6

I tested this with DMD 2.061 on WIndows and Mac OS X.

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



--- Comment #1 from Carlos Santander <csantander@outlook.com> 2013-02-19 19:32:15 EST ---
Created an attachment (id=1193)
test case

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


Maxim Fomin <maxim@maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |maxim@maxim-fomin.ru


--- Comment #2 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-02-20 03:45:03 PST ---
That's because Type::totym() during object file generation got Terror value, which is not switched. Error message can be improved by checking for such value and printing usual error, but the real problem is that Terror escaped frontend.

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



--- Comment #3 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-02-20 03:46:04 PST ---
(In reply to comment #0)
> > Assertion failed: (0), function totym, file glue.c, line 1235.
> > Abort trap: 6
> 
> I tested this with DMD 2.061 on WIndows and Mac OS X.

Can confirm on linux githead.

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



--- Comment #4 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-02-20 05:27:24 PST ---
Reduced:

module failure;

template Tuple(E...) { alias E Tuple; }
alias Tuple!(int) Args;

void main() {
    (new A).test ();
}

void test1 (int delegate (int) f) { f (-2); }

class A
{
    int f (int a) {
        return a;
    }

    void test () {
        test1 (&AddFront!(this, f));
    }
}

template AddFront (alias ctx, alias fun)  {
    auto AddFront(Args args) {
        auto dg (Args dgArgs) {
            return fun (dgArgs);
        }
        dg.ptr = ctx;
        return dg(args);
    }
}

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


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh@gmail.com


--- Comment #5 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2013-04-14 05:24:43 PDT ---
Nice job at reduction.

I'm hitting the same issue while trying to integrate new std.uni into Phobos but the circumstances are different. I'm certainly not trying to do anything funky with delegate pointers.

The message is the same for me (both with your minimal test and when compiling anything in my fork of phobos):

dmd: glue.c:1215: virtual unsigned int Type::totym(): Assertion `0' failed.
Aborted

Now if only dustmite didn't crush on it... we'd have another case.

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


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Platform|x86                         |All


--- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-22 23:03:48 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1911

The root cause is wrong semantic error gagging for UFCS resolving.

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



--- Comment #7 from github-bugzilla@puremagic.com 2013-04-22 23:55:54 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7c2cea2eee75690a6239b5afb53f76c82fc41ecd fix Issue 9540 - Compiler crash on delegate context frame assignment

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


Kenji Hara <k.hara.pg@gmail.com> changed:

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


--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-23 02:18:57 PDT ---
Now the reduced code reports following errors.

test.d(26): Error: function test.A.test.AddFront!(this, f).AddFront.dg (int
_param_0) is not callable using argument types ()
test.d(17): Error: template instance test.A.test.AddFront!(this, f) error
instantiating

        auto dg (Args dgArgs) {
            return fun (dgArgs);
        }
        dg.ptr = ctx;   // <-- line 26

dg is not a delegate, it is a nested function. So it does not have `ptr` property.

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