Skip to content

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

Merged
taiki-e merged 4 commits into
crossbeam-rs:mainfrom
driftluo:port-fix-discard-all-message
Jun 7, 2026
Merged

fix: port fix discard all message on receiver droped#1121
taiki-e merged 4 commits into
crossbeam-rs:mainfrom
driftluo:port-fix-discard-all-message

Conversation

@driftluo

@driftluo driftluo commented Jun 26, 2024

Copy link
Copy Markdown
Contributor

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

taiki-e commented Dec 8, 2024

Copy link
Copy Markdown
Member

@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

driftluo commented Dec 25, 2024

Copy link
Copy Markdown
Contributor Author

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

ryoqun commented Jan 23, 2025

Copy link
Copy Markdown
Contributor

@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

taiki-e commented Jan 23, 2025

Copy link
Copy Markdown
Member

@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
Copy Markdown
Contributor 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 2 times, most recently from 8c20a2e to 2de82b8 Compare January 26, 2025 07:42
@driftluo

Copy link
Copy Markdown
Contributor Author

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

@taiki-e taiki-e removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author label Feb 14, 2026
@taiki-e
taiki-e force-pushed the port-fix-discard-all-message branch from 2de82b8 to f462b47 Compare June 7, 2026 17:56
@taiki-e
taiki-e merged commit 7b573a0 into crossbeam-rs:main Jun 7, 2026
31 checks passed
@taiki-e taiki-e mentioned this pull request Jun 7, 2026
2 tasks
@driftluo
driftluo deleted the port-fix-discard-all-message branch June 8, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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