Skip to content

Mismatched calls to enterFrame and exitFrame when using generators. #2099

@aardvark179

Description

@aardvark179

While testing refactoring of scope handling I've found that we may have mismatched calls to enterFrame and exitFrame while using generators. My stack handling in Context is like this:

    private Scriptable scope;

    public static class StackHandler {

        private final Context cx;
        private final Scriptable oldScope;
        private final Scriptable currentScope;

        private StackHandler(Context cx, Scriptable oldScope, Scriptable newScope) {
            this.cx = cx;
            this.oldScope = oldScope;
            this.currentScope = newScope;
        }

        public void unwind() {
            assert cx.scope == currentScope;
            cx.scope = oldScope;
        }
    }

    public StackHandler pushScope(Scriptable newScope) {
        var res = new StackHandler(this, this.scope, newScope);
        this.scope = newScope;
        return res;
    }

and was done this way specifically to check pushing a scope and unwinding were always done in the right order.

enterFrame was altered to push the scope, and exitFrame to do the unwind. With this change continuation tests fail (which I kind of expected), but so do pretty much all tests which use generators, which suggests we've got a bug regarding those and enter / exit handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions