www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3753] New: ICE eh.c 49: Related to exception handling and alloca.

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

           Summary: ICE eh.c 49:  Related to exception handling and
                    alloca.
           Product: D
           Version: 2.039
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com


--- Comment #0 from David Simcha <dsimcha yahoo.com> 2010-01-29 15:04:57 PST ---
I can't seem to reduce this one to a small test case, but I think this comment
from where the assert fires at least gives a hint that it involves some
combination of exceptions and alloca:

    // BUG: alloca() changes the stack size, which is not reflected
    // in the fixed eh tables.
    assert(!usedalloca);

Also, in the (too large to post to Bugzilla) program that this issue occurred
in, removing the alloca() calls and replacing them with GC.malloc() fixed the
problem.

This assert is in a #if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD ||
TARGET_SOLARIS statement, so I guess it only happens on those OS's.  The code
that triggers it definitely works on Windows.

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


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-01-30 00:53:46 PST ---
(In reply to comment #0)
 I can't seem to reduce this one to a small test case, but I think this comment
 from where the assert fires at least gives a hint that it involves some
 combination of exceptions and alloca:
 
     // BUG: alloca() changes the stack size, which is not reflected
     // in the fixed eh tables.
     assert(!usedalloca);
 
 Also, in the (too large to post to Bugzilla) program that this issue occurred
 in, removing the alloca() calls and replacing them with GC.malloc() fixed the
 problem.
Are you sure you can't cut it down? Without a test case, the chance of it ever getting fixed is pretty remote (basically, you have to wait until someone else hits the same bug and files a test case). Even a huge test case would help. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3753



--- Comment #2 from David Simcha <dsimcha yahoo.com> 2010-01-30 06:48:29 PST ---
import core.stdc.stdlib;

void main(string[] args) {
    try { doNothing(); } catch {}
    void* foo = alloca(args.length);
}

void doNothing() {}

I've had some more time to fiddle with this and more insight into what causes
it, so I've managed to get a reduced test case working.  It seems like you need
to do both of the following in the same function:

1.  Use exception handling either explicitly or implicitly.  This can include
try-catch, try-finally, scope(exit), and struct destructors.

2.  Use alloca, but **the number of bytes must not be a compile-time
constant**.  This is what was messing me up before.  If you replace:

void* foo = alloca(args.length);

with:

void* foo = alloca(8);

then this bug will not be triggered.

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



--- Comment #3 from Don <clugdbug yahoo.com.au> 2010-05-18 00:18:01 PDT ---
I'm including this test case from bug 4054, so that I can close it, as it is
clearly another instance of the same bug.
-------
import core.stdc.stdlib : alloca;
class A { }
void b()
{
        scope a = new A;
        int l;
        alloca(l);
        goto L1;
L1:
        ;
}

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |robert octarineparrot.com


--- Comment #4 from Don <clugdbug yahoo.com.au> 2010-05-18 00:18:41 PDT ---
*** Issue 4054 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 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3753



--- Comment #5 from Brad Roberts <braddr puremagic.com> 2012-07-22 20:00:51 PDT
---
*** Issue 4054 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: -------
Jul 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3753


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE eh.c 49:  Related to    |ICE(eh.c):  Related to
                   |exception handling and      |exception handling and
                   |alloca.                     |alloca.


--- Comment #6 from Don <clugdbug yahoo.com.au> 2013-08-28 00:19:50 PDT ---
Another test case from bug 10575 is also very simple:
---
import core.stdc.stdlib : alloca;

struct TheStruct
{
    ~this()
    {
    }
}

void bar()
{
}

void main()
{
    auto s = TheStruct();
    bar();
    auto a = alloca(16);
}

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


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #7 from Don <clugdbug yahoo.com.au> 2013-08-28 00:20:03 PDT ---
*** Issue 10575 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: -------
Aug 28 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3753


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com
            Version|2.039                       |D2


--- Comment #8 from Walter Bright <bugzilla digitalmars.com> 2013-10-05
11:12:20 PDT ---
Turns assert into reasonable error message:

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

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



--- Comment #9 from github-bugzilla puremagic.com 2013-10-15 16:33:13 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/70709fa628040ad0c968904133ec71b9bbaff5d1
fix Issue 3753 - ICE(eh.c): Related to exception handling and alloca.

https://github.com/D-Programming-Language/dmd/commit/1b5b2ddf9c9ec4c3e6d08d7b80207bd6a7fe47fa
Merge pull request #2630 from WalterBright/fix3753

fix Issue 3753 - ICE(eh.c): Related to exception handling and alloca.

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



--- Comment #10 from github-bugzilla puremagic.com 2013-10-15 16:47:35 PDT ---
Commit pushed to 2.064 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/98ea8217b4986bd6e5cc1ff1b6d5496dc38533cd
Merge pull request #2630 from WalterBright/fix3753

fix Issue 3753 - ICE(eh.c): Related to exception handling and alloca.

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



--- Comment #11 from github-bugzilla puremagic.com 2013-10-15 16:50:09 PDT ---
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d370212fe7613788bcee7391dc733010277d7bd6
Merge pull request #2630 from WalterBright/fix3753

fix Issue 3753 - ICE(eh.c): Related to exception handling and alloca.

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