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

Fix bug in integer range matching #57978

Merged
merged 1 commit into from Feb 1, 2019

Conversation

Projects
None yet
9 participants
@varkor
Copy link
Member

varkor commented Jan 29, 2019

Fixes #57894.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 29, 2019

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@varkor

This comment has been minimized.

Copy link
Member Author

varkor commented Jan 29, 2019

};
if let Some((min, max, sz)) = range {
if let (Some(lo), Some(hi)) = (lo.val.try_to_bits(sz), hi.val.try_to_bits(sz)) {
let (lo, hi) = (lo ^ bias, hi ^ bias);

This comment has been minimized.

@oli-obk

oli-obk Jan 30, 2019

Contributor

So this basically makes sure that unsigned comparison of signed numbers still works out?

This comment has been minimized.

@varkor

varkor Jan 30, 2019

Author Member

Yeah. I'll add a comment.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 31, 2019

The job x86_64-gnu-llvm-6.0 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.
travis_time:end:0d7d7338:start=1548894141300430345,finish=1548894246135799271,duration=104835368926
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---

[00:04:03] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:03] tidy error: /checkout/src/librustc_mir/build/matches/simplify.rs:131: line longer than 100 chars
[00:04:03] tidy error: /checkout/src/librustc_mir/build/matches/simplify.rs:132: line longer than 100 chars
[00:04:03] tidy error: /checkout/src/librustc_mir/build/matches/simplify.rs:133: line longer than 100 chars
[00:04:04] some tidy checks failed
[00:04:04] 
[00:04:04] 
[00:04:04] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:04] 
[00:04:04] 
[00:04:04] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:04] Build completed unsuccessfully in 0:00:49
[00:04:04] Build completed unsuccessfully in 0:00:49
[00:04:04] Makefile:68: recipe for target 'tidy' failed
[00:04:04] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:05ee4d34
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Jan 31 00:28:19 UTC 2019
---
travis_time:end:00e0f77c:start=1548894500722019038,finish=1548894500727289008,duration=5269970
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:101b966b
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0125cf82
travis_time:start:0125cf82
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0245f820
$ dmesg | grep -i kill

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

This comment has been minimized.

Copy link
Contributor

oli-obk commented Jan 31, 2019

@bors r+

};
if let Some((min, max, sz)) = range {
if let (Some(lo), Some(hi)) = (lo.val.try_to_bits(sz), hi.val.try_to_bits(sz)) {
// We want to compare ranges numerically, but the order of signed floating-

This comment has been minimized.

@matthewjasper

matthewjasper Jan 31, 2019

Contributor

Signed integers

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 31, 2019

📌 Commit 441355d has been approved by oli-obk

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Jan 31, 2019

@bors r-

r=me with the comment nit addressed

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Feb 1, 2019

@varkor your update to the comment (8901984) continues to refer to floating-point numbers rather than signed integers (which is what I had interpreted @matthewjasper 's comment nit as referring to).

So now I am inferring that you did in fact mean to reference floating-point numbers in your comment.

I haven't attempted to validate the reasoning in the comment/code when applied to floating-point numbers.

  • (I would be somewhat surprised if such a simple expression actually did suffice for comparing the binary representations of arbitrary floating-point values, but it has been a while since I've been in the depths of software FP implementation...)

But, both your own code here and the referenced code in pattern/_match.rs, is only going to look at ranges constructed from one of the types {char, iN, uN} ... nothing with floating-point type.

... so ... is there some way that floating point values can arise in these code paths? Even the underlying representation in the MIR interpreter, as far as I can tell, avoids using floating-point values...

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Feb 1, 2019

(If in fact floating-point values can arise ... I guess I'd expect to see a unit test illustrating that scenario...)

@varkor

This comment has been minimized.

Copy link
Member Author

varkor commented Feb 1, 2019

Sorry, I must have been distracted when editing the comment; it should not refer to floating-point numbers at all. I think I was conflating it with another problem I've been thinking about recently. Floating-point range patterns are not permitted in this location and do not need to be handled. I shall update the comment (and squash all of the edits) once I get back to my computer. Sorry for the confusion.

@varkor varkor force-pushed the varkor:fix-irrefutable-integer-range-match branch from 8901984 to cd1047e Feb 1, 2019

@varkor

This comment has been minimized.

Copy link
Member Author

varkor commented Feb 1, 2019

@bors r=oli-obk

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 1, 2019

📌 Commit cd1047e has been approved by oli-obk

bors added a commit that referenced this pull request Feb 1, 2019

Auto merge of #57978 - varkor:fix-irrefutable-integer-range-match, r=…
…oli-obk

Fix bug in integer range matching

Fixes #57894.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 1, 2019

⌛️ Testing commit cd1047e with merge 852701a...

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 1, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: oli-obk
Pushing 852701a to master...

@bors bors merged commit cd1047e into rust-lang:master Feb 1, 2019

1 check passed

homu Test successful
Details

@varkor varkor deleted the varkor:fix-irrefutable-integer-range-match branch Feb 2, 2019

bors added a commit that referenced this pull request Feb 4, 2019

Auto merge of #58159 - pietroalbini:beta-backports, r=pietroalbini
[beta] Rollup backports

Cherry-picked:

* #58008: Pass correct arguments to places_conflict
* #58007: Don't panic when accessing enum variant ctor using `Self` in match
* #57978: Fix bug in integer range matching
* #57862: Build the standard library for thumbv7neon-unknown-linux-gnueabihf in CI
* #57659: Fix release manifest generation

r? @ghost

bors added a commit that referenced this pull request Feb 4, 2019

Auto merge of #58159 - pietroalbini:beta-backports, r=pietroalbini
[beta] Rollup backports

Cherry-picked:

* #58008: Pass correct arguments to places_conflict
* #58007: Don't panic when accessing enum variant ctor using `Self` in match
* #57978: Fix bug in integer range matching
* #57862: Build the standard library for thumbv7neon-unknown-linux-gnueabihf in CI
* #57659: Fix release manifest generation

r? @ghost

bors added a commit that referenced this pull request Feb 5, 2019

Auto merge of #58159 - pietroalbini:beta-backports, r=pietroalbini
[beta] Rollup backports

Cherry-picked:

* #58008: Pass correct arguments to places_conflict
* #58007: Don't panic when accessing enum variant ctor using `Self` in match
* #57978: Fix bug in integer range matching
* #57862: Build the standard library for thumbv7neon-unknown-linux-gnueabihf in CI
* #57659: Fix release manifest generation

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