`stop-when`: the fused token's callback can run twice, or be skipped, when the first token is already stopped
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- cpp
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
The issue identifies __stop_when_::__fused_token<T1, T2>::callback_type and gives a reproducer using stdexec/execution.hpp. Read the callback member declarations and constructor initialization order, then run the reproducer to check immediate invocation when the first token is already stopped. Done means the callback runs once at registration and is not called again when the second token stops. Pull request #2327 is already open against this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
__stop_when_::__fused_token<T1, T2>::callback_type declares its once-flag __called_ after the two inner callbacks:
_Fn __fn_;
__cb1_t __cb1_;
__cb2_t __cb2_;
__std::atomic<bool> __called_{false}; // initialized last
If the first token is already stopped, __cb1_'s constructor invokes the callback immediately. That callback does __called_.exchange(true) on an object whose lifetime hasn't started yet. Then __called_'s initializer stores false. So the result depends on the indeterminate value:
- if it was 0: the function runs at registration, the flag is reset, and the function runs a second time when the second token is stopped;
- if it was non-zero: the function is skipped at registration. It runs only if the second token is stopped later, and is lost otherwise.
Both violate [exec.stop.when]: the callback must be invoked when either token is stopped, and at most once.
Introduced in https://github.com/NVIDIA/stdexec/pull/2234
Reproducer
#include <stdexec/execution.hpp>
#include <cstdio>
namespace ex = STDEXEC;
int main() {
ex::inplace_stop_source a, b;
a.request_stop(); // the sender's token is already stopped
int calls = 0, at_registration = -1;
auto probe = ex::read_env(ex::get_stop_token) | ex::then([&](auto token) {
auto fn = [&]() noexcept { ++calls; };
ex::stop_callback_for_t<decltype(token), decltype(fn)> cb(token, fn); // must run: a is stopped
at_registration = calls;
b.request_stop(); // must not run again
});
// The inner stop-when sees a stoppable receiver token (b), so its child gets a fused token.
ex::sync_wait(ex::__stop_when(ex::__stop_when(probe, a.get_token()), b.get_token()));
std::printf("calls at registration: %d (expected 1), in total: %d (expected 1)\n",
at_registration, calls);
return at_registration == 1 && calls == 1 ? 0 : 1;
}
Then output will be: calls at registration: 1 (expected 1), in total: 2 (expected 1). It should be 1 and 1.
- Ngôn ngữ chính
- C++
- Star
- 2.5k
- Fork
- 276
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 65
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA/stdexec
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
NVIDIA/stdexec#1751 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
NVIDIA/stdexec#2337 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 54/100
Maintainer thường phản hồi trong vòng 1 ngày
-
continues_on: hop opstate not connected with secondary environmentCó thể đã có người làm @ericniebler đã nhận 24 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
NVIDIA/stdexec#2268 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NVIDIA/stdexec#2240 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của NVIDIA/stdexec
Issue tương tự
-
ai_p1 comp-message-queues
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ClickHouse/ClickHouse#125890 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
yt-project/ewah_bool_utils#215 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
redis/memtier_benchmark#642 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Feature Request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
sandboxie-plus/Sandboxie#5653 ·
Maintainer thường phản hồi trong vòng 1 ngày