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

Ensure that evaluating or validating a constant never reads from a static #67337

Merged
merged 7 commits into from Dec 24, 2019

Conversation

@oli-obk
Copy link
Contributor

oli-obk commented Dec 15, 2019

r? @RalfJung

as per #66302 (comment)

This does not yet address the fact that evaluation of a constant can read from a static (under unleash-miri)

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Dec 15, 2019

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.
2019-12-15T20:54:40.3441592Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-12-15T20:54:40.3616391Z ##[command]git config gc.auto 0
2019-12-15T20:54:40.3689728Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-12-15T20:54:40.3739773Z ##[command]git config --get-all http.proxy
2019-12-15T20:54:40.3868519Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67337/merge:refs/remotes/pull/67337/merge
---
2019-12-15T21:54:10.4250944Z .................................................................................................... 1600/9382
2019-12-15T21:54:14.8448254Z .................................................................................................... 1700/9382
2019-12-15T21:54:26.7898125Z .....................................................................i.............................. 1800/9382
2019-12-15T21:54:33.7665508Z .................................................................................................... 1900/9382
2019-12-15T21:54:49.2776801Z ......................................................iiiii......................................... 2000/9382
2019-12-15T21:54:59.4036614Z .................................................................................................... 2200/9382
2019-12-15T21:55:01.7462386Z .................................................................................................... 2300/9382
2019-12-15T21:55:04.9285540Z .................................................................................................... 2400/9382
2019-12-15T21:55:27.3445315Z .................................................................................................... 2500/9382
---
2019-12-15T21:58:01.1730095Z ...............................................................i...............i.................... 4800/9382
2019-12-15T21:58:08.5107270Z .................................................................................................... 4900/9382
2019-12-15T21:58:16.7306483Z .................................................................................................... 5000/9382
2019-12-15T21:58:22.1171162Z .......i............................................................................................ 5100/9382
2019-12-15T21:58:32.4859130Z .........................................................................ii.ii...........i.......... 5200/9382
2019-12-15T21:58:41.0214395Z .........i.......................................................................................... 5400/9382
2019-12-15T21:58:50.9049101Z .................................................................................................... 5500/9382
2019-12-15T21:58:57.2433380Z .......................................................i............................................ 5600/9382
2019-12-15T21:59:04.1108443Z .................................................................................................... 5700/9382
2019-12-15T21:59:04.1108443Z .................................................................................................... 5700/9382
2019-12-15T21:59:13.8913322Z .................................................................................................... 5800/9382
2019-12-15T21:59:20.9367252Z ...........................................ii...i..ii...........i................................... 5900/9382
2019-12-15T21:59:42.6458875Z .................................................................................................... 6100/9382
2019-12-15T21:59:50.4871489Z .................................................................................................... 6200/9382
2019-12-15T21:59:50.4871489Z .................................................................................................... 6200/9382
2019-12-15T21:59:57.2878726Z ....................................................................i..ii........................... 6300/9382
2019-12-15T22:00:25.3490142Z .................................................................................................... 6500/9382
2019-12-15T22:00:27.4097381Z ........................................i........................................................... 6600/9382
2019-12-15T22:00:29.4623472Z .................................................................................................... 6700/9382
2019-12-15T22:00:31.7788497Z ................................i................................................................... 6800/9382
---
2019-12-15T22:02:07.2157686Z .................................................................................................... 7400/9382
2019-12-15T22:02:11.7009212Z .................................................................................................... 7500/9382
2019-12-15T22:02:16.6799064Z .................................................................................................... 7600/9382
2019-12-15T22:02:26.0109341Z .................................................................................................... 7700/9382
2019-12-15T22:02:34.7361577Z ......................................................iiii.......................................... 7800/9382
2019-12-15T22:02:48.8939017Z .................................................................................................... 8000/9382
2019-12-15T22:02:54.6450706Z .................................................................................................... 8100/9382
2019-12-15T22:03:10.0577024Z .................................................................................................... 8200/9382
2019-12-15T22:03:17.2368351Z .................................................................................................... 8300/9382
---
2019-12-15T22:05:36.4639234Z ---- [mir-opt] mir-opt/storage_live_dead_in_statics.rs stdout ----
2019-12-15T22:05:36.4639276Z 
2019-12-15T22:05:36.4639329Z error: compilation failed!
2019-12-15T22:05:36.4639562Z status: exit code: 101
2019-12-15T22:05:36.4640644Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/mir-opt/storage_live_dead_in_statics.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "-Zdump-mir=all" "-Zmir-opt-level=3" "-Zdump-mir-exclude-pass-number" "-Zdump-mir-dir=/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt/storage_live_dead_in_statics" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt/storage_live_dead_in_statics/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt/storage_live_dead_in_statics/auxiliary"
2019-12-15T22:05:36.4641971Z ------------------------------------------
2019-12-15T22:05:36.4642147Z 
2019-12-15T22:05:36.4642520Z ------------------------------------------
2019-12-15T22:05:36.4642683Z stderr:
---
2019-12-15T22:05:36.4643730Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-12-15T22:05:36.4643824Z 
2019-12-15T22:05:36.4643906Z note: the compiler unexpectedly panicked. this is a bug.
2019-12-15T22:05:36.4643934Z 
2019-12-15T22:05:36.4644387Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2019-12-15T22:05:36.4644977Z note: rustc 1.41.0-dev running on x86_64-unknown-linux-gnu
2019-12-15T22:05:36.4645118Z 
2019-12-15T22:05:36.4645118Z 
2019-12-15T22:05:36.4645895Z note: compiler flags: -Z threads=1 -Z dump-mir=all -Z mir-opt-level=3 -Z dump-mir-exclude-pass-number -Z dump-mir-dir=/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt/storage_live_dead_in_statics -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
2019-12-15T22:05:36.4646123Z error: aborting due to previous error
2019-12-15T22:05:36.4646247Z 
2019-12-15T22:05:36.4646273Z 
2019-12-15T22:05:36.4646536Z ------------------------------------------
---
2019-12-15T22:05:36.4649726Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-12-15T22:05:36.4649789Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-12-15T22:05:36.4655249Z 
2019-12-15T22:05:36.4655312Z 
2019-12-15T22:05:36.4664236Z 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/mir-opt" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "mir-opt" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/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" "7.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"
2019-12-15T22:05:36.4664588Z 
2019-12-15T22:05:36.4664631Z 
2019-12-15T22:05:36.4710535Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-12-15T22:05:36.4710662Z Build completed unsuccessfully in 1:04:56
2019-12-15T22:05:36.4710662Z Build completed unsuccessfully in 1:04:56
2019-12-15T22:05:36.4769101Z == clock drift check ==
2019-12-15T22:05:36.4783140Z   local time: Sun Dec 15 22:05:36 UTC 2019
2019-12-15T22:05:36.7678076Z   network time: Sun, 15 Dec 2019 22:05:36 GMT
2019-12-15T22:05:36.7681276Z == end clock drift check ==
2019-12-15T22:05:41.0502025Z 
2019-12-15T22:05:41.0603006Z ##[error]Bash exited with code '1'.
2019-12-15T22:05:41.0642321Z ##[section]Starting: Checkout
2019-12-15T22:05:41.0643928Z ==============================================================================
2019-12-15T22:05:41.0643978Z Task         : Get sources
2019-12-15T22:05:41.0644038Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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 Author

oli-obk commented Dec 16, 2019

Oh I just realized this PR makes no sense. If the user points into the static, this PR won't detect that. We could poison Allocations in statics by adding a new flag to them... Or we scrap this approach entirely and just check accesses to statics during interpretation.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Dec 16, 2019

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.
2019-12-16T11:56:56.9967356Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-12-16T11:56:57.0156999Z ##[command]git config gc.auto 0
2019-12-16T11:56:57.0266828Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-12-16T11:56:57.0317048Z ##[command]git config --get-all http.proxy
2019-12-16T11:56:57.0468272Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67337/merge:refs/remotes/pull/67337/merge
---
2019-12-16T12:53:17.4656458Z .................................................................................................... 1600/9385
2019-12-16T12:53:21.2761729Z .................................................................................................... 1700/9385
2019-12-16T12:53:32.7878215Z ........................................................................i........................... 1800/9385
2019-12-16T12:53:39.5390414Z .................................................................................................... 1900/9385
2019-12-16T12:53:53.7735364Z .........................................................iiiii...................................... 2000/9385
2019-12-16T12:54:03.7732858Z .................................................................................................... 2200/9385
2019-12-16T12:54:06.0878738Z .................................................................................................... 2300/9385
2019-12-16T12:54:09.0851367Z .................................................................................................... 2400/9385
2019-12-16T12:54:29.0485577Z .................................................................................................... 2500/9385
---
2019-12-16T12:56:59.6413043Z ..................................................................i...............i................. 4800/9385
2019-12-16T12:57:06.9132918Z .................................................................................................... 4900/9385
2019-12-16T12:57:14.8272686Z .................................................................................................... 5000/9385
2019-12-16T12:57:19.5113626Z ..........i......................................................................................... 5100/9385
2019-12-16T12:57:29.9321254Z ............................................................................ii.ii...........i....... 5200/9385
2019-12-16T12:57:38.1319222Z ............i....................................................................................... 5400/9385
2019-12-16T12:57:47.5825778Z .................................................................................................... 5500/9385
2019-12-16T12:57:53.5250454Z ..........................................................i......................................... 5600/9385
2019-12-16T12:58:00.1383318Z .................................................................................................... 5700/9385
2019-12-16T12:58:00.1383318Z .................................................................................................... 5700/9385
2019-12-16T12:58:09.2941365Z .................................................................................................... 5800/9385
2019-12-16T12:58:16.3197526Z ..............................................ii...i..ii...........i................................ 5900/9385
2019-12-16T12:58:37.3095423Z .................................................................................................... 6100/9385
2019-12-16T12:58:45.0827528Z .................................................................................................... 6200/9385
2019-12-16T12:58:45.0827528Z .................................................................................................... 6200/9385
2019-12-16T12:58:51.6510685Z .......................................................................i..ii........................ 6300/9385
2019-12-16T12:59:18.4786464Z .................................................................................................... 6500/9385
2019-12-16T12:59:20.8627090Z ...........................................i........................................................ 6600/9385
2019-12-16T12:59:22.9565955Z .................................................................................................... 6700/9385
2019-12-16T12:59:25.2836162Z ...................................i................................................................ 6800/9385
---
2019-12-16T13:00:57.7033293Z .................................................................................................... 7400/9385
2019-12-16T13:01:01.6943140Z .................................................................................................... 7500/9385
2019-12-16T13:01:06.6587767Z .................................................................................................... 7600/9385
2019-12-16T13:01:15.8336768Z .................................................................................................... 7700/9385
2019-12-16T13:01:24.8524101Z ........................................................iiii........................................ 7800/9385
2019-12-16T13:01:38.8464008Z .................................................................................................... 8000/9385
2019-12-16T13:01:44.0817128Z .................................................................................................... 8100/9385
2019-12-16T13:01:59.1518703Z .................................................................................................... 8200/9385
2019-12-16T13:02:06.4045101Z .................................................................................................... 8300/9385
---
2019-12-16T13:04:24.2816392Z ---- [mir-opt] mir-opt/storage_live_dead_in_statics.rs stdout ----
2019-12-16T13:04:24.2816437Z 
2019-12-16T13:04:24.2816862Z error: compilation failed!
2019-12-16T13:04:24.2816927Z status: exit code: 101
2019-12-16T13:04:24.2817751Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/mir-opt/storage_live_dead_in_statics.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "-Zdump-mir=all" "-Zmir-opt-level=3" "-Zdump-mir-exclude-pass-number" "-Zdump-mir-dir=/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt/storage_live_dead_in_statics" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt/storage_live_dead_in_statics/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt/storage_live_dead_in_statics/auxiliary"
2019-12-16T13:04:24.2818162Z ------------------------------------------
2019-12-16T13:04:24.2818250Z 
2019-12-16T13:04:24.2818449Z ------------------------------------------
2019-12-16T13:04:24.2818487Z stderr:
---
2019-12-16T13:04:24.2820250Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-12-16T13:04:24.2820735Z 
2019-12-16T13:04:24.2820934Z note: the compiler unexpectedly panicked. this is a bug.
2019-12-16T13:04:24.2821071Z 
2019-12-16T13:04:24.2821721Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2019-12-16T13:04:24.2822545Z note: rustc 1.41.0-dev running on x86_64-unknown-linux-gnu
2019-12-16T13:04:24.2822719Z 
2019-12-16T13:04:24.2822719Z 
2019-12-16T13:04:24.2823337Z note: compiler flags: -Z threads=1 -Z dump-mir=all -Z mir-opt-level=3 -Z dump-mir-exclude-pass-number -Z dump-mir-dir=/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt/storage_live_dead_in_statics -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
2019-12-16T13:04:24.2823838Z error: aborting due to previous error
2019-12-16T13:04:24.2823945Z 
2019-12-16T13:04:24.2824052Z 
2019-12-16T13:04:24.2824537Z ------------------------------------------
---
2019-12-16T13:04:24.2826115Z 
2019-12-16T13:04:24.2826219Z 
2019-12-16T13:04:24.2826613Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-12-16T13:04:24.2826813Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-12-16T13:04:24.2829258Z 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/mir-opt" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "mir-opt" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/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" "7.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"
2019-12-16T13:04:24.2829891Z 
2019-12-16T13:04:24.2830502Z 
2019-12-16T13:04:24.2837872Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-12-16T13:04:24.2838061Z Build completed unsuccessfully in 1:01:46
2019-12-16T13:04:24.2838061Z Build completed unsuccessfully in 1:01:46
2019-12-16T13:04:24.2892560Z == clock drift check ==
2019-12-16T13:04:24.2914244Z   local time: Mon Dec 16 13:04:24 UTC 2019
2019-12-16T13:04:24.5794513Z   network time: Mon, 16 Dec 2019 13:04:24 GMT
2019-12-16T13:04:24.5794624Z == end clock drift check ==
2019-12-16T13:04:28.7609248Z 
2019-12-16T13:04:28.7686440Z ##[error]Bash exited with code '1'.
2019-12-16T13:04:28.7721192Z ##[section]Starting: Checkout
2019-12-16T13:04:28.7723009Z ==============================================================================
2019-12-16T13:04:28.7723065Z Task         : Get sources
2019-12-16T13:04:28.7723114Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@RalfJung

This comment has been minimized.

Copy link
Member

RalfJung commented Dec 16, 2019

Oh I just realized this PR makes no sense. If the user points into the static, this PR won't detect that. We could poison Allocations in statics by adding a new flag to them... Or we scrap this approach entirely and just check accesses to statics during interpretation.

So if I recall correctly, in rust-lang/const-eval#17 (comment) and https://github.com/rust-lang/const-eval/blob/master/const.md#reading-statics, I also came to the conclusion that we want to guard accesses during execution, and not the final value.

@oli-obk oli-obk force-pushed the oli-obk:no_mut_static_ref_from_const branch from 0f986ca to c0faa51 Dec 16, 2019
@RalfJung

This comment has been minimized.

Copy link
Member

RalfJung commented Dec 18, 2019

as per #66302 (comment)

That comment talks about not reading from (mutable) statics. I don't understand the connection to the final value not containing certain relocations.

Oh I just realized this PR makes no sense. If the user points into the static, this PR won't detect that.

Also, isn't code like this allowed?

static FOO: i32 = 13;
const FOOPTR: &i32 = &FOO;

So, I don't entirely understand how we even could backwards-compatibly forbid consts pointing to statics, and why we would want that?

@oli-obk

This comment has been minimized.

Copy link
Contributor Author

oli-obk commented Dec 18, 2019

Also, isn't code like this allowed?

No:

error[E0013]: constants cannot refer to statics, use a constant instead
 --> src/lib.rs:2:22
  |
2 | const FOOPTR: &i32 = &FOO;
  |                      ^^^^
@oli-obk

This comment has been minimized.

Copy link
Contributor Author

oli-obk commented Dec 18, 2019

That comment talks about not reading from (mutable) statics. I don't understand the connection to the final value not containing certain relocations.

Hmm... I guess I went overboard when looking at it from the perspective of the comment, but just referencing a static is not allowed on stable, so this is what we want to forbid right now.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 21, 2019

☔️ The latest upstream changes (presumably #67485) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung

This comment has been minimized.

Copy link
Member

RalfJung commented Dec 22, 2019

Hmm... I guess I went overboard when looking at it from the perspective of the comment, but just referencing a static is not allowed on stable, so this is what we want to forbid right now.

Well, what this PR implement is not accessing a static. So the PR description is wrong, IMO.

Except that, somehow, this also excludes referencing a static, and I am not sure why.

@oli-obk oli-obk force-pushed the oli-obk:no_mut_static_ref_from_const branch from c0faa51 to fc0c48c Dec 22, 2019
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 23, 2019

☔️ The latest upstream changes (presumably #67540) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk oli-obk changed the title Ensure that a constant's final value never contains a relocation into a static Ensure that evaluating or validating a constant never reads from a static Dec 23, 2019
oli-obk and others added 5 commits Dec 16, 2019
and some uses of it will be illegal forever
(e.g. mutable or interior mutable statics)
Co-Authored-By: Ralf Jung <post@ralfj.de>
@oli-obk oli-obk force-pushed the oli-obk:no_mut_static_ref_from_const branch from 3168051 to 89250b9 Dec 23, 2019
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Dec 23, 2019

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.
2019-12-23T14:48:40.5384394Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-12-23T14:48:40.5579767Z ##[command]git config gc.auto 0
2019-12-23T14:48:40.5656063Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-12-23T14:48:40.5700120Z ##[command]git config --get-all http.proxy
2019-12-23T14:48:40.5845230Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67337/merge:refs/remotes/pull/67337/merge
---
2019-12-23T15:45:02.4408080Z .................................................................................................... 1600/9430
2019-12-23T15:45:06.7527759Z .................................................................................................... 1700/9430
2019-12-23T15:45:16.3752853Z F.......................................................................................i........... 1800/9430
2019-12-23T15:45:23.2296325Z .................................................................................................... 1900/9430
2019-12-23T15:45:29.2521604Z .........................................................................iiiii...................... 2000/9430
2019-12-23T15:45:49.0379803Z .................................................................................................... 2200/9430
2019-12-23T15:45:51.2050683Z .................................................................................................... 2300/9430
2019-12-23T15:45:53.5963642Z .................................................................................................... 2400/9430
2019-12-23T15:46:04.1334923Z .................................................................................................... 2500/9430
---
2019-12-23T15:48:44.1522817Z ....i...............i............................................................................... 4900/9430
2019-12-23T15:48:53.5586247Z .................................................................................................... 5000/9430
2019-12-23T15:48:58.1041287Z ................................................i................................................... 5100/9430
2019-12-23T15:49:07.0322888Z .................................................................................................... 5200/9430
2019-12-23T15:49:12.6130035Z ...............ii.ii...........i.................................................................... 5300/9430
2019-12-23T15:49:21.0371366Z .................................................................................................... 5500/9430
2019-12-23T15:49:31.1481369Z .................................................................................................i.. 5600/9430
2019-12-23T15:49:38.7600312Z .................................................................................................... 5700/9430
2019-12-23T15:49:43.4322996Z .................................................................................................... 5800/9430
2019-12-23T15:49:43.4322996Z .................................................................................................... 5800/9430
2019-12-23T15:49:52.4676458Z .....................................................................................ii...i..ii..... 5900/9430
2019-12-23T15:50:12.9447817Z .................................................................................................... 6100/9430
2019-12-23T15:50:20.3420344Z .................................................................................................... 6200/9430
2019-12-23T15:50:27.8063149Z .................................................................................................... 6300/9430
2019-12-23T15:50:27.8063149Z .................................................................................................... 6300/9430
2019-12-23T15:50:47.2222685Z ............i..ii................................................................................... 6400/9430
2019-12-23T15:51:04.9130075Z ........................................................................................i........... 6600/9430
2019-12-23T15:51:06.8432804Z .................................................................................................... 6700/9430
2019-12-23T15:51:08.9292087Z ........................................................................................i........... 6800/9430
2019-12-23T15:51:11.4221100Z .................................................................................................... 6900/9430
---
2019-12-23T15:52:42.8224204Z .................................................................................................... 7500/9430
2019-12-23T15:52:47.4815127Z .................................................................................................... 7600/9430
2019-12-23T15:52:53.9124223Z .................................................................................................... 7700/9430
2019-12-23T15:53:03.8271356Z .................................................................................................... 7800/9430
2019-12-23T15:53:09.7163842Z .iiii............................................................................................... 7900/9430
2019-12-23T15:53:23.2277383Z .................................................................................................... 8100/9430
2019-12-23T15:53:34.0784784Z .................................................................................................... 8200/9430
2019-12-23T15:53:45.1979183Z .................................................................................................... 8300/9430
2019-12-23T15:53:50.4618678Z .................................................................................................... 8400/9430
---
2019-12-23T15:55:36.1797116Z 
2019-12-23T15:55:36.1797713Z ---- [ui] ui/consts/miri_unleashed/mutable_const2.rs stdout ----
2019-12-23T15:55:36.1797780Z diff of stderr:
2019-12-23T15:55:36.1797818Z 
2019-12-23T15:55:36.1798077Z 10 LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
2019-12-23T15:55:36.1798283Z 12 
2019-12-23T15:55:36.1798283Z 12 
2019-12-23T15:55:36.1798689Z - thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:347:17
2019-12-23T15:55:36.1799143Z + thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:349:17
2019-12-23T15:55:36.1800187Z 15 
2019-12-23T15:55:36.1800245Z 16 error: internal compiler error: unexpected panic
2019-12-23T15:55:36.1800302Z 
2019-12-23T15:55:36.1800615Z 
2019-12-23T15:55:36.1800615Z 
2019-12-23T15:55:36.1800687Z The actual stderr differed from the expected stderr.
2019-12-23T15:55:36.1801166Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/mutable_const2/mutable_const2.stderr
2019-12-23T15:55:36.1801893Z To update references, rerun the tests and pass the `--bless` flag
2019-12-23T15:55:36.1802418Z To only update this specific test, also pass `--test-args consts/miri_unleashed/mutable_const2.rs`
2019-12-23T15:55:36.1802763Z error: 1 errors occurred comparing output.
2019-12-23T15:55:36.1802814Z status: exit code: 101
2019-12-23T15:55:36.1802814Z status: exit code: 101
2019-12-23T15:55:36.1803865Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/miri_unleashed/mutable_const2.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/mutable_const2" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zunleash-the-miri-inside-of-you" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/mutable_const2/auxiliary" "-A" "unused"
2019-12-23T15:55:36.1804487Z ------------------------------------------
2019-12-23T15:55:36.1804527Z 
2019-12-23T15:55:36.1804970Z ------------------------------------------
2019-12-23T15:55:36.1805169Z stderr:
2019-12-23T15:55:36.1805169Z stderr:
2019-12-23T15:55:36.1805484Z ------------------------------------------
2019-12-23T15:55:36.1805683Z warning: skipping const checks
2019-12-23T15:55:36.1806035Z   --> /checkout/src/test/ui/consts/miri_unleashed/mutable_const2.rs:15:38
2019-12-23T15:55:36.1806219Z    |
2019-12-23T15:55:36.1806326Z LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
2019-12-23T15:55:36.1806450Z 
2019-12-23T15:55:36.1806514Z error: internal compiler error: mutable allocation in constant
2019-12-23T15:55:36.1806952Z   --> /checkout/src/test/ui/consts/miri_unleashed/mutable_const2.rs:15:1
2019-12-23T15:55:36.1807157Z    |
2019-12-23T15:55:36.1807157Z    |
2019-12-23T15:55:36.1807262Z LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
2019-12-23T15:55:36.1807382Z 
2019-12-23T15:55:36.1807382Z 
2019-12-23T15:55:36.1807786Z thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:349:17
2019-12-23T15:55:36.1808068Z 
2019-12-23T15:55:36.1808118Z error: internal compiler error: unexpected panic
2019-12-23T15:55:36.1808175Z 
2019-12-23T15:55:36.1808264Z note: the compiler unexpectedly panicked. this is a bug.
2019-12-23T15:55:36.1808264Z note: the compiler unexpectedly panicked. this is a bug.
2019-12-23T15:55:36.1808316Z 
2019-12-23T15:55:36.1808820Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2019-12-23T15:55:36.1808861Z 
2019-12-23T15:55:36.1809658Z note: rustc 1.42.0-nightly (4ded390fd 2019-12-23) running on x86_64-unknown-linux-gnu
2019-12-23T15:55:36.1809897Z 
2019-12-23T15:55:36.1810392Z note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -Z unleash-the-miri-inside-of-you -C prefer-dynamic -C rpath -C debuginfo=0
2019-12-23T15:55:36.1810633Z 
2019-12-23T15:55:36.1810981Z ------------------------------------------
2019-12-23T15:55:36.1811144Z 
2019-12-23T15:55:36.1811226Z 
---
2019-12-23T15:55:36.1830883Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:385:22
2019-12-23T15:55:36.1830990Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-12-23T15:55:36.1847631Z 
2019-12-23T15:55:36.1848404Z 
2019-12-23T15:55:36.1850819Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "/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/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/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" "7.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"
2019-12-23T15:55:36.1851387Z 
2019-12-23T15:55:36.1851441Z 
2019-12-23T15:55:36.1865193Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-12-23T15:55:36.1865299Z Build completed unsuccessfully in 1:00:48
2019-12-23T15:55:36.1865299Z Build completed unsuccessfully in 1:00:48
2019-12-23T15:55:36.1921339Z == clock drift check ==
2019-12-23T15:55:36.1940165Z   local time: Mon Dec 23 15:55:36 UTC 2019
2019-12-23T15:55:36.4766259Z   network time: Mon, 23 Dec 2019 15:55:36 GMT
2019-12-23T15:55:36.4771871Z == end clock drift check ==
2019-12-23T15:55:37.4116269Z 
2019-12-23T15:55:37.4201711Z ##[error]Bash exited with code '1'.
2019-12-23T15:55:37.4246723Z ##[section]Starting: Checkout
2019-12-23T15:55:37.4248486Z ==============================================================================
2019-12-23T15:55:37.4248544Z Task         : Get sources
2019-12-23T15:55:37.4248592Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@RalfJung

This comment has been minimized.

Copy link
Member

RalfJung commented Dec 23, 2019

Looking good! r=me with tests blessed.

@oli-obk

This comment has been minimized.

Copy link
Contributor Author

oli-obk commented Dec 23, 2019

@bors r=RalfJung

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 23, 2019

📌 Commit 87fea04 has been approved by RalfJung

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 23, 2019

🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened

bors added a commit that referenced this pull request Dec 24, 2019
Rollup of 7 pull requests

Successful merges:

 - #67192 (Various const eval and pattern matching ICE fixes)
 - #67543 (Add regression tests for fixed ICEs)
 - #67547 (Cleanup err codes)
 - #67551 (Add long error code explanation message for E0627)
 - #67561 (remove `description` from `Error` impls in docs)
 - #67569 (Clean up unsafety in char::encode_utf8)
 - #67572 (Use the chocolatey CDN directly to avoid the flaky API)

Failed merges:

 - #67337 (Ensure that evaluating or validating a constant never reads from a static)

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Dec 24, 2019
…t, r=RalfJung

Ensure that evaluating or validating a constant never reads from a static

r? @RalfJung

as per rust-lang#66302 (comment)

This does not yet address the fact that evaluation of a constant can read from a static (under unleash-miri)
bors added a commit that referenced this pull request Dec 24, 2019
Rollup of 7 pull requests

Successful merges:

 - #67337 (Ensure that evaluating or validating a constant never reads from a static)
 - #67543 (Add regression tests for fixed ICEs)
 - #67547 (Cleanup err codes)
 - #67551 (Add long error code explanation message for E0627)
 - #67561 (remove `description` from `Error` impls in docs)
 - #67569 (Clean up unsafety in char::encode_utf8)
 - #67572 (Use the chocolatey CDN directly to avoid the flaky API)

Failed merges:

r? @ghost
@bors bors merged commit 87fea04 into rust-lang:master Dec 24, 2019
4 checks passed
4 checks passed
pr Build #20191223.85 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.