Skip to content

Fix unsound compat01as03 implementation (fixes #2514)#3012

Merged
taiki-e merged 1 commit into
rust-lang:masterfrom
stbuehler:fix-miri-compat-2514
Jul 18, 2026
Merged

Fix unsound compat01as03 implementation (fixes #2514)#3012
taiki-e merged 1 commit into
rust-lang:masterfrom
stbuehler:fix-miri-compat-2514

Conversation

@stbuehler

@stbuehler stbuehler commented May 24, 2026

Copy link
Copy Markdown
Contributor

Miri complains:

Undefined Behavior: trying to retag [...] for SharedReadWrite
permission [...], but that tag only grants SharedReadOnly permission for
this location

in the UnsafeNotify01::drop_raw implementation for NotifyWaker.

drop_raw should receive a *mut Self, but that isn't dyn compatible; it receives &Self instead (as documented by futures01 UnsafeNotify::drop_raw).

Wrap in and access through UnsafeCell to fix the undefined behavior.

fixes #2514

@rustbot rustbot added A-compat Area: futures::compat S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 24, 2026
@stbuehler
stbuehler force-pushed the fix-miri-compat-2514 branch from f5c0034 to acf18fd Compare July 12, 2026 08:24
@rustbot

This comment has been minimized.

@stbuehler
stbuehler force-pushed the fix-miri-compat-2514 branch from acf18fd to 72b5dca Compare July 12, 2026 08:40
@rustbot rustbot added the A-stream Area: futures::stream label Jul 12, 2026
Miri complains:

> Undefined Behavior: trying to retag [...] for SharedReadWrite
> permission [...], but that tag only grants SharedReadOnly permission for
> this location

in the UnsafeNotify01::drop_raw implementation for NotifyWaker.

drop_raw should receive a `*mut Self`, but that isn't dyn compatible; it
receives `&Self` instead (as documented by futures01
UnsafeNotify::drop_raw).

Wrap in and access through UnsafeCell to fix the undefined behavior.
@stbuehler
stbuehler force-pushed the fix-miri-compat-2514 branch from 72b5dca to 871d40c Compare July 12, 2026 09:47
@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@taiki-e taiki-e left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taiki-e
taiki-e merged commit eff8931 into rust-lang:master Jul 18, 2026
25 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 18, 2026
@taiki-e taiki-e added the 0.3-backport: pending The maintainer accepted to backport this to the 0.3 branch, but backport has not been done yet. label Jul 18, 2026
@taiki-e taiki-e mentioned this pull request Jul 18, 2026
taiki-e pushed a commit that referenced this pull request Jul 18, 2026
Miri complains:

> Undefined Behavior: trying to retag [...] for SharedReadWrite
> permission [...], but that tag only grants SharedReadOnly permission for
> this location

in the UnsafeNotify01::drop_raw implementation for NotifyWaker.

drop_raw should receive a `*mut Self`, but that isn't dyn compatible; it
receives `&Self` instead (as documented by futures01
UnsafeNotify::drop_raw).

Wrap in and access through UnsafeCell to fix the undefined behavior.
@taiki-e

taiki-e commented Jul 18, 2026

Copy link
Copy Markdown
Member

Published in 0.3.33.

@stbuehler
stbuehler deleted the fix-miri-compat-2514 branch July 18, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.3-backport: pending The maintainer accepted to backport this to the 0.3 branch, but backport has not been done yet. A-compat Area: futures::compat A-stream Area: futures::stream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Miri UB warning about compat feature

3 participants