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

Coroutine state transform check_must_not_suspend_ty ignores allocator field of Box #122643

Closed
RalfJung opened this issue Mar 17, 2024 · 2 comments · Fixed by #122701
Closed

Coroutine state transform check_must_not_suspend_ty ignores allocator field of Box #122643

RalfJung opened this issue Mar 17, 2024 · 2 comments · Fixed by #122701
Assignees
Labels
A-coroutines Area: Coroutines T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

RalfJung commented Mar 17, 2024

This code here has a potential issue:

ty::Adt(..) if ty.is_box() => {
let boxed_ty = ty.boxed_ty();
let descr_pre = &format!("{}boxed ", data.descr_pre);
check_must_not_suspend_ty(
tcx,
boxed_ty,
hir_id,
param_env,
SuspendCheckData { descr_pre, ..data },
)
}

If the Box has a custom allocator, then that will not be checked at all. So whatever check_must_not_suspend_ty is used for, it ignores anything stored in custom allocators.

It seems like this is just for a lint, so this is probably not critical, but I guess should still be fixed.

Cc @cjgillot -- not sure whom else to ping for coroutine state machine transform things?

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 17, 2024
@jieyouxu jieyouxu added A-coroutines Area: Coroutines T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 17, 2024
@RalfJung
Copy link
Member Author

Cc @compiler-errors @tmiasko (also a regular occurrence in this file's git log)

@compiler-errors
Copy link
Member

Lol sorry, I thought I had clicked enter on a comment but I must've not. Let me rewrite it.

It seems like this is just for a lint, so this is probably not critical, but I guess should still be fixed.

Yeah, this is approximately the level of urgency you determined. This code exists for an unstable lint, must_not_suspend. I don't expect people to be writing Box<T, MyAllocatorWhichShouldntBeHeldAcrossAwaitPoints>, but technically they could.

@compiler-errors compiler-errors self-assigned this Mar 18, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 18, 2024
… r=oli-obk

Detect allocator for box in `must_not_suspend` lint

I don't expect this to happen in practice, but better to check than not.

Fixes rust-lang#122643
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 18, 2024
… r=oli-obk

Detect allocator for box in `must_not_suspend` lint

I don't expect this to happen in practice, but better to check than not.

Fixes rust-lang#122643
@bors bors closed this as completed in 3c3b398 Mar 18, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 18, 2024
Rollup merge of rust-lang#122701 - compiler-errors:allocator-suspend, r=oli-obk

Detect allocator for box in `must_not_suspend` lint

I don't expect this to happen in practice, but better to check than not.

Fixes rust-lang#122643
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coroutines Area: Coroutines T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants