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

Fix integer overflow in rotate_left #61454

Merged
merged 1 commit into from
Jun 4, 2019
Merged

Conversation

tesuji
Copy link
Contributor

@tesuji tesuji commented Jun 2, 2019

Closes #61406
r? @RalfJung

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 2, 2019
@tesuji

This comment has been minimized.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 2, 2019
@rust-highfive

This comment has been minimized.

@tesuji tesuji force-pushed the ice-rotate_left branch from f675836 to e7964db Compare June 2, 2019 12:57
@@ -3,4 +3,5 @@ fn main() {
//~^ ERROR temporary value dropped while borrowed
let y: &'static i32 = &(5_i32.rotate_right(3));
//~^ ERROR temporary value dropped while borrowed
assert_eq!(0i16.rotate_left(124), 0);
Copy link
Member

Choose a reason for hiding this comment

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

Uh, this is weird. @oli-obk what kind of test is this? I thought it would test functionality for rotate in CTFE but that does not seem to be the case. Do we have any test that does that?

@lzutao in any case, we want to test functionality here, so please move the actual call to within a const item. Something like

const X: i16 = 0i16.rotate_left(124);

Copy link
Contributor

Choose a reason for hiding this comment

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

The above code just checks that we don't promote calls to the rotate_* methods. The actual tests are in https://github.com/rust-lang/rust/blob/9ebf47851a357faa4cd97f4b1dc7835f6376e639/src/test/run-pass/const-int-rotate.rs

Copy link
Member

Choose a reason for hiding this comment

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

Ah, thanks!

Both this test here and that one suffer for a severe lack of comments (e.g. for stuff like the ident function).

@tesuji tesuji force-pushed the ice-rotate_left branch from e7964db to 0532611 Compare June 2, 2019 16:52
@RalfJung
Copy link
Member

RalfJung commented Jun 2, 2019

@lzutao so please move the new test to src/test/run-pass/const-int-rotate.rs. Please also add a test for rotate_right. See this for some inspiration for test cases.

(Oh, and a force-push does not trigger any notifications, so please write a message here when you think this is ready for another round of review. :)

@tesuji tesuji force-pushed the ice-rotate_left branch 3 times, most recently from 531e8f2 to 0b2e00c Compare June 4, 2019 10:36
@rust-highfive
Copy link
Collaborator

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:1b822838:start=1559644782713663012,finish=1559644783537671140,duration=824008128
$ 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
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[01:01:27] .................................................................................................... 100/2923
[01:01:39] .............................................................................i...................... 200/2923
[01:01:48] .................................................................................................... 300/2923
[01:01:59] .................................................................................................... 400/2923
[01:02:08] ....................................F............................................................... 500/2923
[01:02:35] .................................................................................................... 700/2923
[01:02:47] .................................................................................................... 800/2923
[01:02:56] .................................................................................................... 900/2923
[01:03:10] .................................................................................................... 1000/2923
---
[01:07:45] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:521:22
[01:07:45] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:07:45] 
[01:07:45] 
[01:07:45] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:07:45] 
[01:07:45] 
[01:07:45] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:07:45] Build completed unsuccessfully in 1:02:58
---
travis_time:end:1337b82d:start=1559648862274553568,finish=1559648862279712973,duration=5159405
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:01030324
$ 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:12e66b3e
travis_time:start:12e66b3e
$ 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:11f96ec8
$ 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)

@tesuji tesuji force-pushed the ice-rotate_left branch from 0b2e00c to c2e7b21 Compare June 4, 2019 12:02
@tesuji
Copy link
Contributor Author

tesuji commented Jun 4, 2019

@RalfJung I think this PR is ready for review again.

@RalfJung
Copy link
Member

RalfJung commented Jun 4, 2019

This looks great, thanks a lot!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 4, 2019

📌 Commit c2e7b219b2b7714a4cfabf069c324f584139042c has been approved by RalfJung

@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, 2019
@RalfJung
Copy link
Member

RalfJung commented Jun 4, 2019

Actually could you squash the commits and remove the "WIP" from the commit message?

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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, 2019
@tesuji tesuji force-pushed the ice-rotate_left branch from c2e7b21 to d392cb5 Compare June 4, 2019 15:26
@tesuji
Copy link
Contributor Author

tesuji commented Jun 4, 2019

Ping again, I squashed those two commits.

@RalfJung
Copy link
Member

RalfJung commented Jun 4, 2019

Awesome!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 4, 2019

📌 Commit d392cb5 has been approved by RalfJung

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 4, 2019
@tesuji
Copy link
Contributor Author

tesuji commented Jun 4, 2019

@bors rollup

@bors
Copy link
Contributor

bors commented Jun 4, 2019

@lzutao: 🔑 Insufficient privileges: not in try users

@bors
Copy link
Contributor

bors commented Jun 4, 2019

⌛ Testing commit d392cb5 with merge 97c9437...

bors added a commit that referenced this pull request Jun 4, 2019
Fix integer overflow in rotate_left

Closes #61406
r? @RalfJung
@bors
Copy link
Contributor

bors commented Jun 4, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: RalfJung
Pushing 97c9437 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 4, 2019
@bors bors merged commit d392cb5 into rust-lang:master Jun 4, 2019
@tesuji tesuji deleted the ice-rotate_left branch June 5, 2019 00:29
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integer overflow in CTFE implementation of rotate_left
6 participants