Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9a3b8c612a4930778e7e3be17a3ea95707435d76
      
https://github.com/WebKit/WebKit/commit/9a3b8c612a4930778e7e3be17a3ea95707435d76
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-03-18 (Wed, 18 Mar 2026)

  Changed paths:
    A JSTests/stress/async-disposable-stack-dispose-async-many-sync-throws.js
    M Source/JavaScriptCore/builtins/AsyncDisposableStackPrototype.js

  Log Message:
  -----------
  [JSC] Fix stack overflow in AsyncDisposableStack.prototype.disposeAsync
https://bugs.webkit.org/show_bug.cgi?id=310241

Reviewed by Yusuke Suzuki.

The sync-throw path recursed loop -> handleError -> loop. At ~18000
consecutive sync-throwing resources the stack is exhausted and the
RangeError propagates out of disposeAsync synchronously, leaking the
remaining resources.

Inline the error accumulation into the catch block and continue the
while loop instead, matching the sync DisposableStack.prototype.dispose.
DisposeResources [1] step 3.e.ii only Awaits normal completions, so
staying synchronous on throw is correct. handleError is still used via
.@then where each invocation arrives on a fresh microtask frame.

[1]: https://tc39.es/proposal-explicit-resource-management/#sec-disposeresources

Test: JSTests/stress/async-disposable-stack-dispose-async-many-sync-throws.js

* JSTests/stress/async-disposable-stack-dispose-async-many-sync-throws.js: 
Added.
(shouldBe):
(async test.async stack):
(async test):
(test.then):
* Source/JavaScriptCore/builtins/AsyncDisposableStackPrototype.js:
(disposeAsync):

Canonical link: https://commits.webkit.org/309534@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to