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

iterator proxy vs. SetterThatIgnoresPrototypeProperties – infinite recursion #3529

Open
phoddie opened this issue Jan 30, 2025 · 4 comments

Comments

@phoddie
Copy link

phoddie commented Jan 30, 2025

Fuzzilli found a bug in the XS implementation of SetterThatIgnoresPrototypeProperties. After fixing the bug, the result is infinite recursion.

Here is the code (simplified from Fuzzilli):

function trap() {
   return { configurable:true };
}
const array = new Array();
const iterator = array.keys();
const proxy = new Proxy(iterator, { getOwnPropertyDescriptor: trap });
proxy.constructor = {};

Here are the results with eshost:

#### JavaScriptCore

#### SpiderMonkey
InternalError: too much recursion

#### v8

#### XS
Error: stack overflow

We believe that XS is now following the relevant spec steps faithfully.

Note that both XS and SpiderMonkey show infinite recursion, but somehow JSC and v8 do not. What is the expected behavior?

@ljharb
Copy link
Member

ljharb commented Jan 30, 2025

My initial reading suggests that this is indeed an infinite loop for a misconfigured Proxy, and that jsc and v8 aren't matching the spec, but hopefully more folks will weigh in.

@mhofman
Copy link
Member

mhofman commented Jan 30, 2025

I was actually about to report a similar issue, without proxy

Object.create(null, {constructor: Object.getOwnPropertyDescriptor(Iterator.prototype, 'constructor')}).constructor = 'bar'
VM423:1 Uncaught RangeError: Maximum call stack size exceeded

@bakkot
Copy link
Contributor

bakkot commented Jan 30, 2025

I think an infinite loop is the expected behavior, yup. Having a Proxy which reports having a property which the underlying object lacks will often have strange behavior.

@mhofman I don't think that one's an issue; the setter is not designed to be re-homed.

@mhofman
Copy link
Member

mhofman commented Jan 30, 2025

@mhofman I don't think that one's an issue; the setter is not designed to be re-homed.

Yeah it was just very surprising we have an infinite recursion purely in spec code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants