Skip to content

[C++] Potential bug in ReadaheadGenerator #45953

Closed

Description

@mapleFU
          I think below might be a incorrect ordering:

Thread1: check state_->finished.load() == true in 1
Thread2: state->MarkFinishedIfDone, state->final_future.MarkFinished
Thread1: state_->num_running.fetch_add(1) in 2
Thread1: state->final_future.MarkFinished

    auto result = std::move(state_->readahead_queue.front());
    state_->readahead_queue.pop();
    if (state_->finished.load()) { // 1
      state_->readahead_queue.push(AsyncGeneratorEnd<T>());
    } else {
      state_->num_running.fetch_add(1); // 2
      auto back_of_queue = state_->source_generator();
      auto back_of_queue_after_check =
          AddMarkFinishedContinuation(std::move(back_of_queue));
      state_->readahead_queue.push(std::move(back_of_queue_after_check));
    }

Originally posted by @mapleFU in #44990 (comment)

Activity

  1. added a commit that references this issue on Mar 27, 2025
  2. added a commit that references this issue on Mar 27, 2025
  3. added 2 commits that reference this issue on Mar 31, 2025
  4. added this to the 20.0.0 milestone on Mar 31, 2025
  5. mapleFU commented on Mar 31, 2025

    @mapleFU
    MemberAuthor

    Issue resolved by pull request 45954
    #45954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions