www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4481] New: Internal compiler error (glue.c,!vthis->csym) or compiles, depending on the import statements order

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

           Summary: Internal compiler error (glue.c,!vthis->csym) or
                    compiles, depending on the import statements order
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dmitry.olsh gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh gmail.com> 2010-07-17
14:51:38 PDT ---
In some specific circumstances DMD 2.047 segfaults or not segfaults depending
on the order of imported modules. 
The message produced in case of the :
Assertion failure: '!vthis->csym' on line 694 in file 'glue.c'

ATM the reliable set of conditions on which I can reproduce this are:
- at least 2 modules (all source dumped in one file avoids this issue)
- both import std.algorithm (though I still belive it has little to do with it)
- one module defines class which then uses std.reduce 
- another one imports it *and* std.algorithm in a specific order.

Well, it looks like it's very subtle - one slight change and it no longer
manifests. Took almost one day to cut it down to a resonable size. 

//---------------- The test case ----------------
import std.algorithm;//move  this import statement after the next one or just
comment, and everything compiles 
import g;

void main(){}

///g.d
module g;
import std.algorithm;

class Font{// rewriting all of the functions below as free functions and it
again compiles
public:
   int charHeight(dchar c){ return 0; }
   int textHeight(in string text){
     auto maxHeight = (int h,dchar ch){ return max(h,charHeight(ch)); };
     return reduce!(maxHeight)(text);
   }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 17 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #1 from Dmitry Olshansky <dmitry.olsh gmail.com> 2010-07-18
04:43:45 PDT ---
Hm, it has something to with how you pass the files to DMD, for the test case
above:
dmd g.d main.d  - compiles, all Ok
dmd main.d g.d - Assertion failure: '!vthis->csym' on line 694 in file 'glue.c'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 18 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au


--- Comment #2 from Don <clugdbug yahoo.com.au> 2010-07-18 05:30:50 PDT ---
This looks similar to bug 2692. It's not a duplicate, but I suspect the root
cause is the same.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 18 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #3 from Dmitry Olshansky <dmitry.olsh gmail.com> 2010-07-18
13:28:32 PDT ---
(In reply to comment #2)
 This looks similar to bug 2692. It's not a duplicate, but I suspect the root
 cause is the same.
I'm 100% sure you meant bug 2962 that is "ICE(glue.c) or bad codegen passing variable as template value parameter" and not bug 2692 which is "alignment of double on x86 linux is incorrect" and resolved -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 18 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #4 from Don <clugdbug yahoo.com.au> 2010-07-19 12:05:02 PDT ---
(In reply to comment #3)
 (In reply to comment #2)
 This looks similar to bug 2692. It's not a duplicate, but I suspect the root
 cause is the same.
I'm 100% sure you meant bug 2962 that is "ICE(glue.c) or bad codegen passing variable as template value parameter" and not bug 2692 which is "alignment of double on x86 linux is incorrect" and resolved
Correct. In this bug, it's the 'this' parameter which causes the problem, in bug 2962 it's any other function parameter. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481


kekeniro2 yahoo.co.jp changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kekeniro2 yahoo.co.jp


--- Comment #5 from kekeniro2 yahoo.co.jp 2012-05-18 19:16:49 PDT ---
*** Issue 8071 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow gmail.com


--- Comment #6 from Vladimir Panteleev <thecybershadow gmail.com> 2012-05-20
14:55:05 PDT ---
Hit this again today (DMD git, also in 2.059).

In case this bug got buried or thought to be fixed, I'll note that bugs 2692
and 2962 are both marked as fixed, so this bug isn't a duplicate of those.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481


Ola Østtveit <olaa81 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |olaa81 gmail.com


--- Comment #7 from Ola Østtveit <olaa81 gmail.com> 2012-09-06 16:02:13 PDT ---
I got this with dmd 2.060, I got it reduced down to this:

-- main.d
module main;

import std.algorithm;
import collection;
--


-- collection.d
module collection;
import std.algorithm;

struct Collection
{
  int[] collection;

  void test(Collection[] coll)
  {
    auto element = collection[0];

    auto result = coll.map!(v => v.collection[0] * element);
  }
}
--

If the std.algorithm import is commented out in main.d it works fine, also if
element is replaced with collection[0] in the map lambda in collection.d

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 06 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #8 from kekeniro2 yahoo.co.jp 2013-02-17 20:03:35 PST ---
2.062head has a regression caused by this problem, probably.
Reduced test case is here.

Command:
 dmd.exe bug2062a.d bug2062b.d

bug2062a.d ----------------------------
void call(alias pred, R)(R haystack) {
    foreach (e; haystack) {
        pred(e);
        break;
    }
}

bug2062b.d ----------------------------
import bug2062a;

class Foo {
    void member() {
        int[] r;
        int local;
        call!(p=>local)(r); // ( (int p)=>local ) works.
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #9 from kekeniro2 yahoo.co.jp 2013-02-18 02:39:58 PST ---
(In reply to comment #8)
Sorry, 2.062 has just come, and it doesn't reproduce above.
Then, it was not a regression in 2.062head, but in 2.063head(or master).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru


--- Comment #10 from Maxim Fomin <maxim maxim-fomin.ru> 2013-02-18 03:54:36 PST
---
I cannot reproduce neither of three samples (original, comment 7, comment 8).
Tested with today released 2.062 on windows.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #11 from kekeniro2 yahoo.co.jp 2013-02-18 05:20:02 PST ---
I see.
I did wrong process.
We should get source from 'staging' branch to check if bugs are fixed, not from
'master'.

So, it is not a regression.
Sorry to have bothered you.

And this issue seems to be fixed in 2.062, I agree.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481


jack.un gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jack.un gmail.com


--- Comment #12 from jack.un gmail.com 2013-06-02 02:17:47 PDT ---
2.063 has another variant of this still. If i use struct with opCall (because
my sort needs a third variable) then it still crashes depending what order it
is imported.

Crashes with glue.c:786: virtual void FuncDeclaration::toObjFile(int):
Assertion `!vthis->csym' failed.


//crash.d
// import anything a bit complex
import std.stdio; // crash
import crashb;
import std.stdio; //no crash

void main()
{
    auto a = new A;
    a.sort();
}


///crashb.d
module crashb;
import std.algorithm;

struct Sorter
{
    bool opCall(int a, int b)
    {
        return a < b;
    }
}

class A
{
    void sort()
    {
        uint[] s;
        Sorter sorter;
        std.algorithm.sort!sorter(s);
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #13 from kekeniro2 yahoo.co.jp 2013-07-30 00:08:55 PDT ---
Here is another variant of this.

[DMD2.063.2]
dmd crasha.d crashb.d
===> Assertion failure: '!vthis->csym' on line 783 in file 'glue.c'

// crasha.d ---------------------
import std.algorithm;

// crashb.d ---------------------
import std.algorithm;

class SomeClass {
    void foo() {
        //enum myFilter = function(int s)=>true; // OK
        auto myFilter = function(int s)=>true;   // NG
        int[] r;
        r.filter!myFilter();
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481


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

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


--- Comment #14 from Kenji Hara <k.hara.pg gmail.com> 2013-08-11 04:27:14 PDT
---
https://github.com/D-Programming-Language/dmd/pull/2463

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #15 from github-bugzilla puremagic.com 2013-08-11 17:07:14 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/165f15bf71537f863943599f4782b6c0b54c37eb
fix Issue 4481 - ICE(glue.c,!vthis->csym) or compiles, depending on the import
statements order

https://github.com/D-Programming-Language/dmd/commit/2389c3552b44467a77861a61be445eb09a4a376f
Merge pull request #2463 from 9rnsr/fix4481

Issue 4481 - ICE(glue.c,!vthis->csym) or compiles, depending on the import
statements order

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4481


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

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


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