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

CTFE: simplify ConstValue by not checking for alignment #63079

Merged
merged 5 commits into from
Aug 5, 2019

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jul 28, 2019

I hope the test suite actually covers the problematic cases here?

r? @oli-obk

Fixes #61952

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 28, 2019
@RalfJung RalfJung changed the title CTFE: simplify Value type by not checking for alignment CTFE: simplify ConstValue by not checking for alignment Jul 28, 2019
@rust-highfive

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 28, 2019

What do you think about removing the align field of Mplace in const eval by making it an assoc type of the Engine?

@RalfJung
Copy link
Member Author

What do you think about removing the align field of Mplace in const eval by making it an assoc type of the Engine?

Hm. Not sure how well that code would factor.

With #63075, we actually don't need the align field in places any more. However, my expectation is that for raw pointers we might eventually want to relax the rule that says "when you do *ptr, even if you are just computing a field offset, the ptr must be aligned and dereferencable". So I am reluctant to remove all that infrastructure if we have to bring it back later.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 28, 2019

I don't want to remove the field. Miri will keep using it. Const eval doesn't need it though. If you do UB in const eval, we don't promise we catch it.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 28, 2019

We should probably find a way to make miri's const_eval query run with all miri-checks on.

@RalfJung
Copy link
Member Author

RalfJung commented Jul 28, 2019

Miri will keep using it.

With #63075 the field is effectively dead in Miri, though. For now. I think.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 28, 2019

Ah, ok. We can revisit once that is resolved then. Can you make sure that it's documented $somewhere in the process, so that we actually do revisit?

r=me with travis green

@RalfJung
Copy link
Member Author

Const eval doesn't need it though.

Agreed. But factoring that through the Machine trait will be somewhat messy: MPlaceTy and PlaceTy would get another generic parameter; and the check_ptr_access method in Memory would end up split across both sides of the interface.

@RalfJung
Copy link
Member Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Jul 28, 2019

📌 Commit cfb13b0eeb620dee597a99c4100b1464f589b731 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 28, 2019
@bors
Copy link
Contributor

bors commented Jul 29, 2019

⌛ Testing commit cfb13b0eeb620dee597a99c4100b1464f589b731 with merge 4034b4c3188a41efb8be7f415d0252d232da06b4...

@bors
Copy link
Contributor

bors commented Jul 29, 2019

💔 Test failed - checks-azure

@rust-highfive

This comment has been minimized.

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 29, 2019
@RalfJung
Copy link
Member Author

@oli-obk @Centril I made validity check alignment even when the machine does not. I am not very happy with check_ptr_access_align as method name though.

(Also that CI failure looks spurious.)

@bors

This comment has been minimized.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 2, 2019

Rebased. @oli-obk what do you think of checking alignment in validity even when the machine otherwise ignores alignment (as is now implemented here)?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 5, 2019

I think it's very reasonable. We can always weaken validity checks if we need to. Hardening them is not easy to do.

@bors r+

@bors
Copy link
Contributor

bors commented Aug 5, 2019

📌 Commit 0cf4329 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 5, 2019
@bors
Copy link
Contributor

bors commented Aug 5, 2019

⌛ Testing commit 0cf4329 with merge 4be0675...

bors added a commit that referenced this pull request Aug 5, 2019
CTFE: simplify ConstValue by not checking for alignment

I hope the test suite actually covers the problematic cases here?

r? @oli-obk

Fixes #61952
@bors
Copy link
Contributor

bors commented Aug 5, 2019

☀️ Test successful - checks-azure
Approved by: oli-obk
Pushing 4be0675 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 5, 2019
@bors bors merged commit 0cf4329 into rust-lang:master Aug 5, 2019
@RalfJung RalfJung deleted the ctfe-no-align branch August 5, 2019 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Const eval does alignment checks
5 participants