Thread overview
[Issue 4750] New: fail_compilation/fail225.d causes dmd to segv
Aug 29, 2010
Brad Roberts
Aug 30, 2010
Don
Aug 30, 2010
Brad Roberts
Aug 31, 2010
Brad Roberts
Feb 14, 2011
Brad Roberts
Feb 14, 2011
Brad Roberts
Feb 14, 2011
Brad Roberts
Feb 14, 2011
Brad Roberts
Feb 14, 2011
Brad Roberts
Mar 03, 2011
Brad Roberts
August 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4750

           Summary: fail_compilation/fail225.d causes dmd to segv
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: braddr@puremagic.com


--- Comment #0 from Brad Roberts <braddr@puremagic.com> 2010-08-29 00:04:04 PDT ---
to repro, from $(DMD_SVN_ROOT)/src/test:

make test_results/fail_compilation/fail225.d.out

or:

../src/dmd -Ifail_compilation -odtest_results/fail_compilation -oftest_results/fail_compilation/fail225 -c fail_compilation/fail225.d

The code:

struct Struct {
        char* chptr;
}

void main()
{
        char ch = 'd';
        invariant Struct iStruct = {1, &ch};
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4750



--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-08-30 14:01:38 PDT ---
I cannot reproduce this (on Windows). I tried 2.048, and svn 646, svn 647, svn
648, svn 651.
In every case, I get:

bad.d(18): Error: cannot implicitly convert expression (1) of type int to char*
bad.d(18): Error: too many initializers for Struct
bad.d(18): Error: variable bad.main.iStruct is not a static and cannot have
stat
ic initializer

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4750



--- Comment #2 from Brad Roberts <braddr@puremagic.com> 2010-08-30 15:07:13 PDT ---
I'll sync up tonight and re-verify on linux.  If it segv's still, I'll dig into what's up.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 31, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4750



--- Comment #3 from Brad Roberts <braddr@puremagic.com> 2010-08-30 23:29:58 PDT ---
ok, tested on linux with r652:

$ gdb --args ../src/dmd -Ifail_compilation -odtest_results/fail_compilation -oftest_results/fail_compilation/fail225 -c fail_compilation/fail225.d

fail_compilation/fail225.d(8): Error: cannot implicitly convert expression (1)
of type int to char*
fail_compilation/fail225.d(8): Error: too many initializers for Struct

Program received signal SIGSEGV, Segmentation fault.
0x080b322c in Type::isImmutable (this=0x0) at mtype.h:255
255         int isImmutable()   { return mod & MODimmutable; }

(gdb) up
#1  0x0812f10b in Type::invariantOf (this=0x0) at mtype.c:381
381         if (isImmutable())
(gdb)
#2  0x08053c16 in StructLiteralExp::implicitConvTo (this=0x823e390,
t=0x8242f78) at cast.c:433
433                     te = te->invariantOf();
(gdb) print te
$1 = (Type *) 0x0
(gdb) print t->mod
$2 = 4 '\004'
(gdb) print *e
$3 = {
  <Object> = {
    _vptr.Object = 0x81c5ee8
  },
  members of Expression:
  loc = {
    filename = 0x820e188 "fail_compilation/fail225.d",
    linnum = 8
  },
  op = TOKaddress,
  type = 0x0,
  size = 28 '\034',
  parens = 0 '\000'
}

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



--- Comment #4 from Brad Roberts <braddr@puremagic.com> 2011-02-13 17:36:48 PST ---
I just re-tried this one.  It still fails on linux but not on windows.  Odd.

#0  0x080b5f22 in Type::isImmutable (this=0x0) at mtype.h:256
#1  0x08134fbb in Type::invariantOf (this=0x0) at mtype.c:383
#2  0x08136cc3 in Type::castMod (this=0x0, mod=4) at mtype.c:1079
#3  0x080538b5 in StructLiteralExp::implicitConvTo (this=0x8250da8,
t=0x8255a18) at cast.c:429
#4  0x080b3bb7 in VarDeclaration::semantic (this=0x821edd0, sc=0x8255730) at
declaration.c:1175
#5  0x080e089f in DeclarationExp::semantic (this=0x821ee78, sc=0x8255620) at
expression.c:4707
#6  0x0816b76a in ExpStatement::semantic (this=0x821ee60, sc=0x8255620) at
statement.c:256
#7  0x0816c36e in CompoundStatement::semantic (this=0x821eea8, sc=0x8255620) at
statement.c:483
#8  0x080fd84a in FuncDeclaration::semantic3 (this=0x821e918, sc=0x8255590) at
func.c:1239
#9  0x081333b2 in Module::semantic3 (this=0x821e1d8) at module.c:859
#10 0x08130884 in main (argc=13, argv=0x8214510) at mars.c:1204

#3  0x080538b5 in StructLiteralExp::implicitConvTo (this=0x8250da8,
t=0x8255a18) at cast.c:429
429                 te = te->castMod(t->mod)

te is null
e->toChars() --> &ch

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



--- Comment #5 from Brad Roberts <braddr@puremagic.com> 2011-02-13 21:08:41 PST ---
Ok, te is null in windows as well, but for whatever reason, it's not seg faulting.

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



--- Comment #6 from Brad Roberts <braddr@puremagic.com> 2011-02-13 21:47:33 PST ---
Created an attachment (id=908)
fix a few error handling paths

Several of the error paths in StructInitializer::semantic fail to set errors which can lead to continuing to work with half built objects.

I'm not sure this is the right fix, but it does fix the segv produced by the dmd failure test fail225.d and doesn't break any existing tests.

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


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|nobody@puremagic.com        |bugzilla@digitalmars.com


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



--- Comment #7 from Brad Roberts <braddr@puremagic.com> 2011-02-13 21:51:23 PST ---
see also: https://github.com/D-Programming-Language/dmd/pull/8

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 03, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4750


Brad Roberts <braddr@puremagic.com> changed:

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


--- Comment #8 from Brad Roberts <braddr@puremagic.com> 2011-03-03 01:00:53 PST ---
https://github.com/D-Programming-Language/dmd/commit/e199b4858775a417460ddea598aaf2f4f114dcae

https://github.com/D-Programming-Language/dmd/commit/e3a7ca4f8c3c922b23d8d897a260b21849525b5f

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