[Issue 5176] Limit static object sizes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 10 11:46:13 PST 2013


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



--- Comment #25 from hsteoh at quickfur.ath.cx 2013-01-10 11:46:07 PST ---
(In reply to comment #17)
> Windows inserts a "guard page" that is hardware protected beyond the end of the
> allocated stack. A stack overflow runs into that guard page, which throws a seg
> fault.
> 
> It does not corrupt memory.

Oh yes it does:

http://d.puremagic.com/test-results/pull.ghtml?projectid=1&runid=448588

(But I did make a mistake, it's not Linux that this happens on, but OSX/64.)

For reference, this is the failing code (N.B. the last assert, compare with
output in the autotester, you can see that garbage values are produced, I've
traced this and found that it's caused by stack overflow):

unittest
{
    struct TransientRange
    {
        dchar[128] _buf;
        dstring[] _values;
        this(dstring[] values)
        {
            _values = values;
        }
        @property bool empty()
        {
            return _values.length == 0;
        }
        @property auto front()
        {
            foreach (i; 0 .. _values.front.length)
            {
                _buf[i] = _values[0][i];
            }
            return _buf[0 .. _values.front.length];
        }
        void popFront()
        {
            _values = _values[1 .. $];
        }
    }

    auto rr = TransientRange(["abc"d, "12"d, "def"d, "34"d]);

    // Can't use array() or equal() directly because they fail with transient
    // .front.
    dchar[] result;
    foreach (c; rr.joiner()) {
        result ~= c;
    }

    assert(equal(result, "abc12def34"d),
        "Unexpected result: '%s'"d.format(result));
}

-- 
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