Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(oneshot channel): ensure msg won't be dropped on sender side when send returns ok #6558
feat(oneshot channel): ensure msg won't be dropped on sender side when send returns ok #6558
Changes from 9 commits
c7c22a0
97e0afc
60bc726
b7c5c8c
605315a
71d2f48
4d6e04e
f5acc3c
76f4b49
d94f373
aaf09f0
4a8f1ff
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the newly added code in
oneshot.rs
is removed, we will hit this assertion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just call
drop(rx)
on the main thread. Spawning threads is very expensive in loom tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a try.
If I simply use
drop(rx)
in the main thread, when I revert the changes inoneshot.rs
, the assertion cannot be hit, and if I do it in a spawned thread, the assertion can be hit.I doubt that only
drop(rx)
in a separate thread can cover the case in loom.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you hit the assertion with
LOOM_MAX_PREEMPTIONS=2
? That's what we run with in CI.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, when I set it to 2, the assertion can be hit.
Should the
CONTRIBUTING.md
be updated? I ran the loom test following the guide in it.tokio/CONTRIBUTING.md
Line 195 in df77063
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes a lot longer to run with the option set to 2, and most bugs can be caught with the value set to 1. It may be better to have your test use the loom test builder to explicitly set the max preemptions to 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Have updated the code.