www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10074] New: segfault in dmd

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

           Summary: segfault in dmd
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jens.k.mueller gmx.de


--- Comment #0 from jens.k.mueller gmx.de 2013-05-13 05:15:50 PDT ---
The following program causes dmd (dmd2.062) to segfault on Linux.

template foo(F)                                                                 
{                                                                               
    enum foo = false;                                                           
}                                                                               

bool foo(F)(F f)                                                                
    if (foo!F)                                                                  
{                                                                               
    return false;                                                               
}                                                                               

void main()                                                                     
{                                                                               
    foo(1);                                                                     
}

$ dmd test.d
segmentation fault  dmd test.d

I expect the program to compile or abort with an error but there should be no
segfault.

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2013-10-01
20:16:59 PDT ---
It's actually a stack overflow, endlessly repeating:

#61 0x080ba021 in ScopeExp::semantic (this=0x9fa2ee8, sc=0x9fa2f08) at
expression.c:5018
#62 0x0817d987 in TemplateDeclaration::matchWithInstance (this=0x8294908,
sc=0x9fa2978,
    ti=0x9fa2858, dedtypes=0xff5ffa5c, fargs=0x0, flag=0) at template.c:928
#63 0x0818ad2e in TemplateInstance::ParamNeedsInf::fp (this=0xff5ffa50,
s=0x8294908)
    at template.c:6522
#64 0x0818a95d in TemplateInstance::ParamNeedsInf::fp (param=0xff5ffa50,
s=0x8294908)
    at template.c:6434
#65 0x080e6807 in overloadApply (fstart=0x8294428, param=0xff5ffa50,
    fp=0x818a945 <TemplateInstance::ParamNeedsInf::fp(void*, Dsymbol*)>) at
func.c:2446
#66 0x0818ae6b in TemplateInstance::needsTypeInference (this=0x9fa2858,
sc=0x9fa2978, flag=0)
    at template.c:6548

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



--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2013-10-01
20:50:09 PDT ---
It's looking at the constraint:

    if (foo!F)

recursively in attempting to see if the template instantiation needs type
inference.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
            Version|unspecified                 |D2
           Severity|normal                      |regression


--- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2013-10-01 22:32:44 PDT ---
This is a regression issue from 2.061.

https://github.com/D-Programming-Language/dmd/pull/2613

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



--- Comment #4 from github-bugzilla puremagic.com 2013-10-02 10:07:48 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/209c0d4f6b058472559d9ed3b8076bddf1e2c1e5
fix Issue 10074 - segfault in dmd

From 2.061, `deduceFunctionTemplate` has been using
TemplateDeclaration::matchWithInstance to do IFTI more strictly.
However, `matchWithInstance` does not detect the recursive template
instantiation inside template constraint, against
`deduceFunctionTemplateMatch`.

Duplicate the detection mechanism into `matchWithInstance`.

https://github.com/D-Programming-Language/dmd/commit/457acb1e03257fbff3ad52477d44d0d08ebb2d3e
Merge pull request #2613 from 9rnsr/fix10074

[REG2.061] Issue 10074 - segfault in dmd

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


Walter Bright <bugzilla digitalmars.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: -------
Oct 02 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10074


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

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


--- Comment #5 from Kenji Hara <k.hara.pg gmail.com> 2013-10-10 23:19:51 PDT ---
*** Issue 11067 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: -------
Oct 10 2013