[Webkit-unassigned] [Bug 151482] New: JSContext Promise resolve tasks too eager, can result in infinite loop

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Nov 19 21:54:59 PST 2015


https://bugs.webkit.org/show_bug.cgi?id=151482

            Bug ID: 151482
           Summary: JSContext Promise resolve tasks too eager, can result
                    in infinite loop
    Classification: Unclassified
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: joepeck at webkit.org
                CC: ggaren at apple.com, keith_miller at apple.com,
                    mark.lam at apple.com, utatane.tea at gmail.com

* SUMMARY
JSContext Promise resolve tasks too eager, can result in infinite loop.

Not sure if we should just treat this as behaves correctly or not. Technically this code does create an infinite loop of "jobs", but it doesn't need to execute in such a 100% hang like it does.

* TEST
JSContext *context = [[JSContext alloc] init];
NSString *script = @""
    "function makeAndResolvePromise() {\n"
    "   Promise.resolve(1).then(function() {\n"
    "       console.log('resolved');\n"
    "       makeAndResolvePromise();\n" // Comment out this line to avoid infinite loop.
    "   });\n"
    "};\n"
    "makeAndResolvePromise();";

NSLog(@">>> Before");
[context evaluateScript:script];
NSLog(@">>> After"); // Never reached

* NOTES
- Promise.resolve.then will immediately queue a task to run the then callback at the end of this JS event loop (when the VM becomes idle)
  - that callback then runs and resolves a promise with a then callback, queued to run at the end of this JS event loop (when the VM becomes idle)
    - that callback then runs and resolves a promise with a then callback, queued to run at the end of this JS event loop (when the VM becomes idle)
      ...

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20151120/170275ec/attachment.html>


More information about the webkit-unassigned mailing list