[Issue 3560] foreach on closure corrupted after function call

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 13 15:12:16 PDT 2010


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


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|foreach on closure          |foreach on closure
                   |corrupted after varargs     |corrupted after function
                   |call                        |call
         OS/Version|Linux                       |All
           Severity|major                       |critical


--- Comment #2 from Don <clugdbug at yahoo.com.au> 2010-07-13 15:12:13 PDT ---
Further reduction shows that it doesn't require varargs. Raising priority to
critical, since it means that virtually all closures are broken.
What's happening: on the call to inner, EAX should hold a pointer to
the closure variables (on the heap). But when there's another function call,
it's using EBX instead, and the EAX value is whatever garbage is left after the
function call.
So it gets the calling convention wrong.
====================

void bug3560(int x){ }

void main()
{
    int localvar = 7;

    int inner(int delegate(ref int) dg) {
        int k = localvar; // BUG: &localvar == 0x24 (!)
        return 0;
    }
    bug3560(0x20);
    foreach (entry; &inner) { }
}

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