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

Use box in shadow memory test for reliable object count #3380

Closed

Conversation

tautschnig
Copy link
Member

When using stack-allocated objects, MIR is not actually introducing fresh objects in this loop. Us treating them as fresh objects is just an artifact of interpreting StorageLive as creating a fresh object. Using box will make sure we genuinely have independent objects.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

When using stack-allocated objects, MIR is not actually introducing
fresh objects in this loop. Us treating them as fresh objects is just an
artifact of interpreting StorageLive as creating a fresh object. Using
`box` will make sure we genuinely have independent objects.
@tautschnig tautschnig requested a review from a team as a code owner July 24, 2024 19:44
let x = i;
assert_eq!(kani::mem::pointer_object(&x as *const usize), i + 2);
let x: Box<usize> = Box::new(i);
assert_eq!(kani::mem::pointer_object(&*x as *const usize), 2 * i + 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for the multiplication by 2? Is there an object for the box and another for the variable x? If so, would inlining the Box:new operation in the assert remove the doubling?

@tautschnig
Copy link
Member Author

Closing as this has been made part of #2995.

@tautschnig tautschnig closed this Aug 1, 2024
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.

2 participants