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

recursive static initialization is broken #120

Closed
solson opened this issue Feb 7, 2017 · 2 comments · Fixed by #121
Closed

recursive static initialization is broken #120

solson opened this issue Feb 7, 2017 · 2 comments · Fixed by #121
Labels
C-bug Category: This is a bug.

Comments

@solson
Copy link
Member

solson commented Feb 7, 2017

I investigated the only "tried to modify constant memory" in #55 and it's due to the fact that Miri can't properly initialize statics that recursively refer to each other. This would be low priority since it only affects the unstable #![feature(static_recursion)], but the feature looks like it will be stable soon.

E.g.

struct S(&'static S);
static S1: S = S(&S2);
static S2: S = S(&S1);

When you start initializing S1:

  1. you'll start initializing S2 because it's required (ConstantExtractor)
  2. write the final result for S2
  3. freeze S2 and all allocations it references (this freezes S1)
  4. pick up where you left off initializing S1
  5. write the final result for S1 (fails because it's frozen)
@solson solson added the C-bug Category: This is a bug. label Feb 7, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Feb 7, 2017

I gotta run. can you try what happens with the PR I just opened?

oli-obk added a commit to oli-obk/miri that referenced this issue Feb 7, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Feb 7, 2017

it's also fixed by #121

erickt pushed a commit to erickt/miri that referenced this issue Feb 4, 2022
Rename entry_index to get_index_of
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants