Skip to content

Don't ignore generator fields in miri #60889

Description

@tmandry

Right now, saved locals in generators are special-cased in miri, because they might not always be initialized.

With #59897 and #60187, we have the framework to fix this: fields are now only put in generator variants where they are live. The problem remains with aggregate fields, however, e.g.

fn gen() {
  let x: (i32, i32);
  x.0 = 5;
  yield;
  dbg!(x.0);
}

In this case x.1 is never initialized. This still presents a special case, because we cannot have a partially-unitialized field in a regular struct or enum type.

One way to remove the special-casing in miri is to wrap the type of every generator field in MaybeUninitialized when we return it from rustc::ty::layout::field(). This required making MaybeUnitialized a lang item, though, and doesn't actually give us any new features.

Eventually, I think we'd like to handle aggregate fields explicitly, so we can sanitize UB in generators.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-coroutinesArea: CoroutinesA-miriArea: The miri toolAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions