fix(runtime): Promise async-resolution / microtask-ordering test262 tail#5026
Merged
Conversation
…resolving-fn arity built-ins/Promise test262 506/574 (88.2%) -> 511/574 (89.0%), +5, zero regressions. Two root causes: 1. Promise.prototype.finally invoked onFinally with ONE argument (js_closure_call1(on_finally, undefined)) instead of zero. The spec calls onFinally with no arguments, so every test that asserts arguments.length === 0 inside the cleanup callback failed. Switched to js_closure_call0. (finally/resolution-value-no-override, rejection-reason-no-fulfill, rejection-reason-override-with-throw.) 2. The native resolving functions (promise_resolve_fn / promise_reject_fn and the PromiseResolveThenableJob resolve/reject) are extern "C" fn(closure, value). When a thenable's then calls resolve() with NO args (spec 27.2.1.3.2), js_closure_call0 fell to its zero-arg direct-call arm and the function read a GARBAGE second register (surfacing as the denormal 5e-324, bits=1), corrupting the resolution value. Registering these bodies' dispatch arity (= 1) makes the missing value pad to undefined. (exception-after-resolve-in-executor, exception-after-resolve-in-thenable-job.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
built-ins/Promise test262: 506/574 (88.2%) → 511/574 (89.0%), +5, zero regressions (verified by diffing the per-test failure set before/after).
Two shared root causes in the async-resolution path:
1.
Promise.prototype.finallycalledonFinallywith one argument instead of zero. The wrapper invokedjs_closure_call1(on_finally, undefined), soarguments.lengthreported 1. The spec invokesonFinallywith no arguments — switched tojs_closure_call0. Fixes the finally cases that assert a zero-arg cleanup invocation (resolution-value-no-override,rejection-reason-no-fulfill,rejection-reason-override-with-throw).2. Native resolving functions read a garbage value when called with too few args.
promise_resolve_fn/promise_reject_fnand thePromiseResolveThenableJobresolve/reject closures areextern "C" fn(closure, value). When a thenable'sthendoesresolve()with no arguments (spec 27.2.1.3.2 step 9),js_closure_call0fell to its zero-arg direct-call arm and the function read an uninitialized second register — surfacing as the denormal5e-324(bits = 1) and corrupting the resolution value. Registering these bodies' dispatch arity (= 1, once per thread) makes the missingvaluepad toundefined. Fixesexception-after-resolve-in-executorandexception-after-resolve-in-thenable-job.Files
promise/then.rs— finally zero-arg invocationpromise/combinators.rs—ensure_native_resolving_arity_registeredValidation
test262_subset.py --dir built-ins/Promiseagainst tc39/test262 @4249661, Node v26.3.0 oracle: pass 506→511, 0 newly-broken. (The remaining tail is dominated by SpeciesConstructor / subclassed-Promise capability machinery, deferred to avoid hot-path risk.)