Skip to content
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

fix: port fix discard all message on receiver droped #1121

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

driftluo
Copy link

@driftluo driftluo commented Jun 26, 2024

fix #1102

I think this fix should be done on the crossbeam channel

@driftluo driftluo force-pushed the port-fix-discard-all-message branch from 331102b to bbff85d Compare June 26, 2024 03:11
@taiki-e
Copy link
Member

taiki-e commented Dec 8, 2024

@taiki-e taiki-e added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author label Dec 8, 2024
@driftluo driftluo force-pushed the port-fix-discard-all-message branch from bb15d37 to 65e7ecf Compare December 25, 2024 07:12
@driftluo
Copy link
Author

driftluo commented Dec 25, 2024

Thanks for the PR. It seems that Miri and sanitizer reports memory leak: https://github.com/crossbeam-rs/crossbeam/actions/runs/12221429705/job/34090460906?pr=1121#step:4:168 https://github.com/crossbeam-rs/crossbeam/actions/runs/12221429705/job/34090462020?pr=1121#step:5:186

The memory leak reported by miri is the panic_on_drop test case, which seems to be the expected behavior, because https://github.com/rust-lang/rust/blob/master/library/std/src/sync/mpmc/array.rs#L487-L489 The comment here indicates that if there is a panic, a memory leak will occur

I think std seems to assume that this behavior is expected. Do we need to make some extra efforts for this?

If necessary, should panic::catch_unwind be used to catch the assume_init_drop? can't do this

@ryoqun
Copy link
Contributor

ryoqun commented Jan 23, 2025

@taiki-e hi, is there some timeline for merging this bug-fix pr? is there some blocker? my pr #1114 is touching same area of code and i'd rather to rework my pr once after this pr landed...

@taiki-e
Copy link
Member

taiki-e commented Jan 23, 2025

@driftluo

The memory leak reported by miri is the panic_on_drop test case, which seems to be the expected behavior, because https://github.com/rust-lang/rust/blob/master/library/std/src/sync/mpmc/array.rs#L487-L489 The comment here indicates that if there is a panic, a memory leak will occur

I think std seems to assume that this behavior is expected. Do we need to make some extra efforts for this?

Assuming this PR is based on the rust-lang/rust PR I reviewed, the implementation should be fine with this. (But if so, please make that clear when submitting a patch based on someone else's work.)

That said, we cannot merge PRs that have not passed CI, so you will need to adjust the failing test. (Perhaps a similar way to 2d3430f 's MIRI_LEAK_CHECK=1 approach is fine.)

@driftluo driftluo force-pushed the port-fix-discard-all-message branch 6 times, most recently from 88ae19e to 73da61c Compare January 24, 2025 06:52
@driftluo
Copy link
Author

@taiki-e I use -Zmiri-ignore-leaks to disable Miri test on the channel test, but on sanitizer test, I can't find any flag to ignore it

@driftluo driftluo force-pushed the port-fix-discard-all-message branch from c43d56b to 8c20a2e Compare January 26, 2025 07:15
@driftluo driftluo force-pushed the port-fix-discard-all-message branch from 8c20a2e to 2de82b8 Compare January 26, 2025 07:42
@driftluo
Copy link
Author

@taiki-e ok, I ignore panic_on_drop test on sanitizer, now ci is pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crossbeam-channel S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author
Development

Successfully merging this pull request may close these issues.

Potential deadlock and resource leak when Receiver is dropped in crossbeam_channel's bounded channel
3 participants