Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflect.has triggers getters on global object contextified by vm #52737

Open
lachrist opened this issue Apr 28, 2024 · 3 comments
Open

Reflect.has triggers getters on global object contextified by vm #52737

lachrist opened this issue Apr 28, 2024 · 3 comments
Labels
vm Issues and PRs related to the vm subsystem.

Comments

@lachrist
Copy link

Version

v20.12.2

Platform

Darwin Laurents-MacBook-Air.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:59:33 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8112 arm64

Subsystem

vm

What steps will reproduce the bug?

import { createContext, runInContext } from "vm";
runInContext(
  `
    "use strict";
    Reflect.defineProperty(globalThis, "FOO", {
      get: () => {
        throw new Error("This should not get triggered");
      },
    });
    Reflect.has(globalThis, "FOO");
  `,
  createContext(),
);

How often does it reproduce? Is there a required condition?

All the time.

What is the expected behavior? Why is that the expected behavior?

Reflect.has should never trigger getter.

What do you see instead?

Reflect.has triggers getters for contextified global object. This is somehow similar to #52720 in that it makes contextified global objects break some invariants of the language.

In case anyone is wondering, I use vm to avoid having to spawn a new node process for each test cases of the test262 suite. These invariant breakages make some of them fail.

Maybe vm's contextified object are meant to be "magical" and I should stop reporting these issues. But then I feel this information would be a worthwhile addition to the doc.

Additional information

No response

lachrist pushed a commit to lachrist/aran that referenced this issue Apr 28, 2024
lachrist pushed a commit to lachrist/aran that referenced this issue Apr 28, 2024
@aduh95
Copy link
Contributor

aduh95 commented Apr 28, 2024

I'm not able to reproduce on the latest main. It looks like it's already been fixed, but the fix has not landed on 20.x.

@benjamingr
Copy link
Member

Can confirm this repros on v20.12.2 but not on v22.0, I recall a fix (by @fhinkel ?) for something in that space a few months ago.

@lachrist
Copy link
Author

Same here, this issue does not show on my setup on 22.0.0. I wrongly assumed it would have because of #52720

@VoltrexKeyva VoltrexKeyva added the vm Issues and PRs related to the vm subsystem. label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants