[Issue 8774] 2.059 worked 2.060 does not: nested delegate memory corruption

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 26 21:30:57 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #28 from Walter Bright <bugzilla at digitalmars.com> 2012-12-26 21:30:55 PST ---
A further reduced test case:

-----------------
void popFront()
{
    int[20] abc;        // smash stack
}

struct MapResult(alias fun)
{
    void delegate() front()
    {
        return fun(1);
    }
}

void main() {

    int sliceSize = 100;

    void delegate() foo( int i )
    {
        void delegate() closedPartialSum()
        {
            int ii = i ;
            void bar()
            {   assert(sliceSize == 100);
            }
            return &bar;
        }
        return closedPartialSum();
    }

    auto threads = MapResult!foo();

    auto dg = threads.front();
    popFront();

    dg();
}
-----------------

Most of the oddities in the original were there to "smash" the stack, which we
do here with a simple array initialization. Apparently, there are out-of-scope
dangling references into the stack which cause the seg fault.

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


More information about the Digitalmars-d-bugs mailing list