Futures Impl when called recursively with multi-threaded executors can breach continuation chain depth limit

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • ALL
    • Programmability 2025-08-18
    • 0
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When recursing with the futures runtime (example below) using a multi-threaded executor, multiple threads in the executor can race to complete continuations before the "original" invoking thread can collapse the futures chain inside propagateResultTo. This breaches the depth limit inside `transitionToFinished` when run under a debug build, but does not otherwise appear to have correctness impacts.

      Future<T> doWhile(executor, ...) {
        // When this return statement completes, the thread that called
        // doWhile will call propagateResultsTo.
        // But if the executor completes the continuation before propagate
        // completes, the futures chain builds instead of collapsing due
        // to isJustForContinuation.
        // When the iterations are fast enough and the thread pool large
        // enough this temporary chaining breaches the depth limit on
        // future_impl.h:438 
        return executor.schedule([&] {
          return doWhile(executor, ...);
        });
      }

              Assignee:
              James Bronsted
              Reporter:
              Myles Hathcock
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated: