Skip to content

ScalarPairs are offset==0 field + other non-zst field #51307

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

Merged
merged 2 commits into from
Jun 5, 2018

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jun 2, 2018

r? @eddyb

fixes #51300

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 2, 2018
@@ -137,7 +137,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
Value::Scalar(_) if offset.bytes() == 0 && field.size == base_layout.size => Ok(Some((base, field.ty))),
// split fat pointers, 2 element tuples, ...
Value::ScalarPair(a, b) if base_layout.fields.count() == 2 => {
let val = [a, b][field_index];
let val = [a, b][base_layout.fields.memory_index(field_index)];
Copy link
Member

Choose a reason for hiding this comment

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

This is still not a good idea (if you want to see what happens, try adding a bunch of ZSTs) - what you want is to check whether offset.bytes() == 0 or not. I could've sworn I already wrote the code in this module to do it correctly, are there several similar pieces of code in here?

if let Value::ScalarPair(_, value) = other {
write_next(value)?;
if let Value::ScalarPair(a, b) = other {
write_next([a, b][layout.fields.memory_index(1)])?;
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@@ -221,7 +221,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
trace!("layout computed");
use rustc_data_structures::indexed_vec::Idx;
let field_index = field.index();
let val = [a, b][field_index];
let val = [a, b][base_layout.fields.memory_index(field_index)];
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@oli-obk oli-obk changed the title ScalarPairs are ordered in memory order ScalarPairs are offset==0 field + other non-zst field Jun 3, 2018
Value::Scalar(_) => bug!("Scalar does not cover entire type"),
};
let dest =
self.eval_place(&mir::Place::Local(arg_local))?;
Copy link
Member

Choose a reason for hiding this comment

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

Why not do something like this for the source, too?

_ => None,
}
let (value, field_ty) = self.use_ecx(span, |this| {
this.ecx.read_field(base, None, field, ty)
Copy link
Member

Choose a reason for hiding this comment

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

Like this, maybe?

@@ -136,8 +136,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
Value::ScalarPair(..) |
Value::Scalar(_) if offset.bytes() == 0 && field.size == base_layout.size => Ok(Some((base, field.ty))),
// split fat pointers, 2 element tuples, ...
Copy link
Member

Choose a reason for hiding this comment

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

This comment is too specific.

@eddyb
Copy link
Member

eddyb commented Jun 4, 2018

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 4, 2018

📌 Commit f7eedfa has been approved by eddyb

@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 Jun 4, 2018
@bors
Copy link
Collaborator

bors commented Jun 4, 2018

⌛ Testing commit f7eedfa with merge 4baf141bf291b89ec611558c28ea995733055246...

@bors
Copy link
Collaborator

bors commented Jun 4, 2018

💔 Test failed - status-travis

@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 Jun 4, 2018
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-distcheck of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[02:58:30] test [run-make] run-make-fulldeps/windows-spawn ... ok
[02:58:30] test [run-make] run-make-fulldeps/volatile-intrinsics ... ok
[02:58:31] test [run-make] run-make-fulldeps/windows-subsystem ... ok
[02:58:33] test [run-make] run-make-fulldeps/sysroot-crates-are-unstable ... ok
The job exceeded the maximum time limit for jobs, and has been terminated.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

1 similar comment
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-distcheck of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[02:58:30] test [run-make] run-make-fulldeps/windows-spawn ... ok
[02:58:30] test [run-make] run-make-fulldeps/volatile-intrinsics ... ok
[02:58:31] test [run-make] run-make-fulldeps/windows-subsystem ... ok
[02:58:33] test [run-make] run-make-fulldeps/sysroot-crates-are-unstable ... ok
The job exceeded the maximum time limit for jobs, and has been terminated.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 4, 2018

all builders took less than 2h except for the dist builder, which timed out after 3h 😕

@pietroalbini
Copy link
Member

@bors retry

@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 Jun 4, 2018
@bors
Copy link
Collaborator

bors commented Jun 4, 2018

⌛ Testing commit f7eedfa with merge c610be9...

bors added a commit that referenced this pull request Jun 4, 2018
ScalarPairs are offset==0 field + other non-zst field

r? @eddyb

fixes #51300
@bors
Copy link
Collaborator

bors commented Jun 5, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing c610be9 to master...

@bors bors merged commit f7eedfa into rust-lang:master Jun 5, 2018
@oli-obk oli-obk deleted the miri_fixes branch June 5, 2018 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Constant evaluation error: attempted to read undefined bytes
5 participants