LibJS: Cache length identifier for GetLengthWithThis
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

We cached the length identifier for GetLength, but not
GetLengthWithThis. This caused an `has_value()` verification failure
when accessing super.length. Found by Fuzzilli.
This commit is contained in:
Luke Wilde 2025-04-07 12:35:23 +01:00 committed by Andreas Kling
parent 408f9f3dde
commit 25e343464d
Notes: github-actions[bot] 2025-04-07 12:41:43 +00:00
2 changed files with 23 additions and 0 deletions

View file

@ -1116,6 +1116,7 @@ void Generator::emit_get_by_id(ScopedOperand dst, ScopedOperand base, Identifier
void Generator::emit_get_by_id_with_this(ScopedOperand dst, ScopedOperand base, IdentifierTableIndex id, ScopedOperand this_value)
{
if (m_identifier_table->get(id) == "length"sv) {
m_length_identifier = id;
emit<Op::GetLengthWithThis>(dst, base, this_value, m_next_property_lookup_cache++);
return;
}

View file

@ -0,0 +1,22 @@
test("does not crash when accessing super.length", () => {
let result;
class A {
constructor() {}
get length() {
return 2;
}
}
class B extends A {
constructor() {
super();
result = super.length;
}
}
new B();
expect(result).toBe(2);
});