Skip to content

Add a protector test that demonstrates the base tag diagnostic #2523

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

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Aug 31, 2022

Per #2519 (comment), this demonstrates this case for protector diagnostics:

help: <3131> was created here, as a base tag for alloc1623
  --> tests/fail/stacked_borrows/invalidate_against_protector3.rs:10:19
   |
10 |         let ptr = std::alloc::alloc(std::alloc::Layout::for_value(&0i32)) as *mut i32;
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This diagnostic is inspired by what Miri used to do with rust-lang/rust#60076 (comment)

@RalfJung
Copy link
Member

The diagnostic cannot just happen for protectors, right? At least that function that computes it seems to be more generic than just protectors.

@saethlin
Copy link
Member Author

saethlin commented Sep 1, 2022

The diagnostic cannot just happen for protectors, right?

I think actually it can only happen for protectors. When the problem is that the used pointer has been invalidated, we print the creation span of the invalidated pointer, not the invalidating pointer. And since you can't invalidate the base tag, I don't think we'll ever print its span.

We also can't print the base tag's creation span for a use-outside-provenance issue, because the base tag is always valid for the whole allocation. And the base tag always has write permission.

@saethlin saethlin force-pushed the protector-test branch 2 times, most recently from 89a4030 to 70be91d Compare September 1, 2022 00:30
@RalfJung
Copy link
Member

RalfJung commented Sep 1, 2022

I think actually it can only happen for protectors.

Ah, makes sense, thanks.

@RalfJung
Copy link
Member

RalfJung commented Sep 1, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Sep 1, 2022

📌 Commit 3cfb991 has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Sep 1, 2022

⌛ Testing commit 3cfb991 with merge 2d50443...

@bors
Copy link
Contributor

bors commented Sep 1, 2022

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 2d50443 to master...

@bors bors merged commit 2d50443 into rust-lang:master Sep 1, 2022
@saethlin saethlin deleted the protector-test branch September 13, 2022 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants