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

Debug #48116. #48127

Closed
wants to merge 3 commits into from
Closed

Debug #48116. #48127

wants to merge 3 commits into from

Conversation

kennytm
Copy link
Member

@kennytm kennytm commented Feb 10, 2018

  1. When the invalid condition is hit, write out the relevant variables too
  2. In compile-fail/parse-fail tests, check for ICE first, so the invalid error patterns won't mask our ICE output.

r? @alexcrichton
cc #48116, cc @eddyb

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 10, 2018
@eddyb
Copy link
Member

eddyb commented Feb 10, 2018

@bors r+ p=1

@bors
Copy link
Contributor

bors commented Feb 10, 2018

📌 Commit 9f015ee 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 Feb 10, 2018
@bors
Copy link
Contributor

bors commented Feb 10, 2018

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

@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 Feb 10, 2018
@estebank
Copy link
Contributor

@kennytm Needs rebase.

@kennytm
Copy link
Member Author

kennytm commented Feb 11, 2018

Okay okay

@kennytm
Copy link
Member Author

kennytm commented Feb 11, 2018

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Feb 11, 2018

📌 Commit 3337d51 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 11, 2018
@bors
Copy link
Contributor

bors commented Feb 11, 2018

⌛ Testing commit 3337d51 with merge 790e7b2fcfdefa3b583b45d05b20c7de9862d5c4...

@bors
Copy link
Contributor

bors commented Feb 11, 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 Feb 11, 2018
@kennytm
Copy link
Member Author

kennytm commented Feb 11, 2018

Perfect, hit #48116 😂

I think we could take a look at the result before retrying.

  • x = "::extern"

  • span = Span { lo: BytePos(525), hi: BytePos(531), ctxt: #0 }

  • global = false,

  • names = [],

  • subclass =

    SingleImport { 
        target: extern#0, 
        source: extern#0, 
        result: PerNS { 
            value_ns: Cell { value: Err(Determined) }, 
            type_ns: Cell { value: Err(Determined) }, 
            macro_ns: None 
        }, 
        type_ns_only: false 
    }
[01:51:01] failures:
[01:51:01] 
[01:51:01] ---- [compile-fail] compile-fail/rfc-2126-extern-in-paths/single-segment.rs stdout ----
[01:51:01] 	
[01:51:01] error: compiler encountered internal error
[01:51:01] status: exit code: 101
[01:51:01] command: "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/stage2/bin/rustc" "/Users/travis/build/rust-lang/rust/src/test/compile-fail/rfc-2126-extern-in-paths/single-segment.rs" "-L" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail" "--target=x86_64-apple-darwin" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail/rfc-2126-extern-in-paths/single-segment.stage2-x86_64-apple-darwin" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/native/rust-test-helpers" "-L" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail/rfc-2126-extern-in-paths/single-segment.stage2-x86_64-apple-darwin.aux" "-A" "unused"
[01:51:01] stdout:
[01:51:01] ------------------------------------------
[01:51:01] 
[01:51:01] ------------------------------------------
[01:51:01] stderr:
[01:51:01] ------------------------------------------
[01:51:01] {"message":"unresolved import `extern::*`","code":{"code":"E0432","explanation":"\nAn import was unresolved.\n\nErroneous code example:\n\n```compile_fail,E0432\nuse something::Foo; // error: unresolved import `something::Foo`.\n```\n\nPaths in `use` statements are relative to the crate root. To import items\nrelative to the current and parent modules, use the `self::` and `super::`\nprefixes, respectively. Also verify that you didn't misspell the import\nname and that the import exists in the module from where you tried to\nimport it. Example:\n\n```\nuse self::something::Foo; // ok!\n\nmod something {\n    pub struct Foo;\n}\n# fn main() {}\n```\n\nOr, if you tried to use a module from an external crate, you may have missed\nthe `extern crate` declaration (which is usually placed in the crate root):\n\n```\nextern crate core; // Required to use the `core` crate\n\nuse core::any;\n# fn main() {}\n```\n"},"level":"error","spans":[{"file_name":"/Users/travis/build/rust-lang/rust/src/test/compile-fail/rfc-2126-extern-in-paths/single-segment.rs","byte_start":620,"byte_end":629,"line_start":17,"line_end":17,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"use extern::*; //~ ERROR unresolved import `extern::*`","highlight_start":5,"highlight_end":14}],"label":"cannot glob-import all possible crates","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0432]: unresolved import `extern::*`\n  --> /Users/travis/build/rust-lang/rust/src/test/compile-fail/rfc-2126-extern-in-paths/single-segment.rs:17:5\n   |\n17 | use extern::*; //~ ERROR unresolved import `extern::*`\n   |     ^^^^^^^^^ cannot glob-import all possible crates\n\n"}
[01:51:01] thread 'rustc' panicked at 'librustc_resolve/resolve_imports.rs:1040: invalid name `::extern` at Span { lo: BytePos(525), hi: BytePos(531), ctxt: #0 }; global = false, names = [], subclass = SingleImport { target: extern#0, source: extern#0, result: PerNS { value_ns: Cell { value: Err(Determined) }, type_ns: Cell { value: Err(Determined) }, macro_ns: None }, type_ns_only: false }', librustc/session/mod.rs:1180:26
[01:51:01] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:51:01] 
[01:51:01] error: internal compiler error: unexpected panic
[01:51:01] 
[01:51:01] note: the compiler unexpectedly panicked. this is a bug.
[01:51:01] 
[01:51:01] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[01:51:01] 
[01:51:01] note: rustc 1.25.0-dev running on x86_64-apple-darwin
[01:51:01] 
[01:51:01] 
[01:51:01] ------------------------------------------
[01:51:01] 
[01:51:01] thread '[compile-fail] compile-fail/rfc-2126-extern-in-paths/single-segment.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2883:9
[01:51:01] 
[01:51:01] ---- [compile-fail] compile-fail/use-keyword.rs stdout ----
[01:51:01] 	
[01:51:01] error: compiler encountered internal error
[01:51:01] status: exit code: 101
[01:51:01] command: "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/stage2/bin/rustc" "/Users/travis/build/rust-lang/rust/src/test/compile-fail/use-keyword.rs" "-L" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail" "--target=x86_64-apple-darwin" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail/use-keyword.stage2-x86_64-apple-darwin" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/native/rust-test-helpers" "-L" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail/use-keyword.stage2-x86_64-apple-darwin.aux" "-A" "unused"
[01:51:01] stdout:
[01:51:01] ------------------------------------------
[01:51:01] 
[01:51:01] ------------------------------------------
[01:51:01] stderr:
[01:51:01] ------------------------------------------
[01:51:01] {"message":"`self` imports are only allowed within a { } list","code":{"code":"E0429","explanation":"\nThe `self` keyword cannot appear alone as the last segment in a `use`\ndeclaration.\n\nErroneous code example:\n\n```compile_fail,E0429\nuse std::fmt::self; // error: `self` imports are only allowed within a { } list\n```\n\nTo use a namespace itself in addition to some of its members, `self` may appear\nas part of a brace-enclosed list of imports:\n\n```\nuse std::fmt::{self, Debug};\n```\n\nIf you only want to import the namespace, do so directly:\n\n```\nuse std::fmt;\n```\n"},"level":"error","spans":[{"file_name":"/Users/travis/build/rust-lang/rust/src/test/compile-fail/use-keyword.rs","byte_start":634,"byte_end":643,"line_start":16,"line_end":16,"column_start":13,"column_end":22,"is_primary":true,"text":[{"text":"        use self as A;","highlight_start":13,"highlight_end":22}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0429]: `self` imports are only allowed within a { } list\n  --> /Users/travis/build/rust-lang/rust/src/test/compile-fail/use-keyword.rs:16:13\n   |\n16 |         use self as A;\n   |             ^^^^^^^^^\n\n"}
[01:51:01] thread 'rustc' panicked at 'librustc_resolve/resolve_imports.rs:1040: invalid name `::super` at Span { lo: BytePos(726), hi: BytePos(736), ctxt: #0 }; global = false, names = [], subclass = SingleImport { target: B#0, source: super#0, result: PerNS { value_ns: Cell { value: Err(Determined) }, type_ns: Cell { value: Err(Determined) }, macro_ns: None }, type_ns_only: false }', librustc/session/mod.rs:1180:26
[01:51:01] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:51:01] 
[01:51:01] error: internal compiler error: unexpected panic
[01:51:01] 
[01:51:01] note: the compiler unexpectedly panicked. this is a bug.
[01:51:01] 
[01:51:01] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[01:51:01] 
[01:51:01] note: rustc 1.25.0-dev running on x86_64-apple-darwin
[01:51:01] 
[01:51:01] 
[01:51:01] ------------------------------------------
[01:51:01] 
[01:51:01] thread '[compile-fail] compile-fail/use-keyword.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2883:9
[01:51:01] 
[01:51:01] ---- [compile-fail] compile-fail/use-mod-2.rs stdout ----
[01:51:01] 	
[01:51:01] error: compiler encountered internal error
[01:51:01] status: exit code: 101
[01:51:01] command: "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/stage2/bin/rustc" "/Users/travis/build/rust-lang/rust/src/test/compile-fail/use-mod-2.rs" "-L" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail" "--target=x86_64-apple-darwin" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail/use-mod-2.stage2-x86_64-apple-darwin" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/native/rust-test-helpers" "-L" "/Users/travis/build/rust-lang/rust/build/x86_64-apple-darwin/test/compile-fail/use-mod-2.stage2-x86_64-apple-darwin.aux" "-A" "unused"
[01:51:01] stdout:
[01:51:01] ------------------------------------------
[01:51:01] 
[01:51:01] ------------------------------------------
[01:51:01] stderr:
[01:51:01] ------------------------------------------
[01:51:01] thread 'rustc' panicked at 'librustc_resolve/resolve_imports.rs:1040: invalid name `::self` at Span { lo: BytePos(492), hi: BytePos(496), ctxt: #0 }; global = false, names = [], subclass = SingleImport { target: self#0, source: self#0, result: PerNS { value_ns: Cell { value: Err(Undetermined) }, type_ns: Cell { value: Err(Determined) }, macro_ns: None }, type_ns_only: true }', librustc/session/mod.rs:1180:26
[01:51:01] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:51:01] 
[01:51:01] error: internal compiler error: unexpected panic
[01:51:01] 
[01:51:01] note: the compiler unexpectedly panicked. this is a bug.
[01:51:01] 
[01:51:01] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[01:51:01] 
[01:51:01] note: rustc 1.25.0-dev running on x86_64-apple-darwin
[01:51:01] 
[01:51:01] 
[01:51:01] ------------------------------------------
[01:51:01] 
[01:51:01] thread '[compile-fail] compile-fail/use-mod-2.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2883:9
[01:51:01] 
[01:51:01] 
[01:51:01] failures:
[01:51:01]     [compile-fail] compile-fail/rfc-2126-extern-in-paths/single-segment.rs
[01:51:01]     [compile-fail] compile-fail/use-keyword.rs
[01:51:01]     [compile-fail] compile-fail/use-mod-2.rs

@kennytm kennytm 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 11, 2018
@eddyb
Copy link
Member

eddyb commented Feb 11, 2018

Okay, looks like outer if names.is_empty() is broken and enters the else for some reason.

@alexcrichton
Copy link
Member

What I'm curious about is what in the world is nondeterministic to cause this?

@kennytm
Copy link
Member Author

kennytm commented Feb 11, 2018

Since we've got the reason of failure, I'm transforming this PR for debugging.

@kennytm kennytm changed the title Improve debuggability of #48116. [WIP] Debug #48116. Feb 11, 2018
@kennytm
Copy link
Member Author

kennytm commented Feb 11, 2018

@bors try

@bors
Copy link
Contributor

bors commented Feb 11, 2018

⌛ Trying commit b292325 with merge 36d3769...

bors added a commit that referenced this pull request Feb 11, 2018
[WIP] Debug #48116.

1. When the invalid condition is hit, write out the relevant variables too
2. In compile-fail/parse-fail tests, check for ICE first, so the invalid error patterns won't mask our ICE output.

r? @alexcrichton
cc #48116, cc @eddyb
@bors
Copy link
Contributor

bors commented Feb 11, 2018

💔 Test failed - status-travis

1. When the invalid condition is hit, write out the relevant variables too
2. In compile-fail/parse-fail tests, check for ICE first, so the invalid
   error patterns won't mask our ICE output.
@kennytm kennytm force-pushed the debug-48116 branch 2 times, most recently from d2ca440 to 7c54f2a Compare February 13, 2018 07:12
@kennytm kennytm changed the title [WIP] Debug #48116. Debug #48116. Feb 13, 2018
@kennytm
Copy link
Member Author

kennytm commented Feb 13, 2018

(Needs to test the magic power of the auto branch. The PR should fail immediately, so it shouldn't block the queue.)

@bors r+ p=52

@bors
Copy link
Contributor

bors commented Feb 13, 2018

📌 Commit 4f95269 has been approved by kennytm

@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 Feb 13, 2018
@bors
Copy link
Contributor

bors commented Feb 13, 2018

⌛ Testing commit 4f95269 with merge 3ca6eed5832800d513ead5f11927ed1a4f7bf2ef...

@bors
Copy link
Contributor

bors commented Feb 13, 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 Feb 13, 2018
@kennytm
Copy link
Member Author

kennytm commented Feb 13, 2018

cancelbot is too aggressive, there should be some way to let cancelbot ignore manual restarts... 😐

@kennytm kennytm 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 13, 2018
@kennytm kennytm closed this Feb 14, 2018
@kennytm kennytm deleted the debug-48116 branch February 14, 2018 15:19
bors added a commit that referenced this pull request Feb 14, 2018
Try to fix 48116 and 48192

The bug #48116 happens because of a misoptimization of the `import_path_to_string` function, where a `names` slice is empty but the `!names.is_empty()` branch is executed.

https://github.com/rust-lang/rust/blob/4d2d3fc5dadf894a8ad709a5860a549f2c0b1032/src/librustc_resolve/resolve_imports.rs#L1015-L1042

Yesterday, @eddyb had locally reproduced the bug, and [came across the `position` function](https://mozilla.logbot.info/rust-infra/20180214#c14296834) where the `assume()` call is found to be suspicious. We have *not* concluded that this `assume()` causes #48116, but given [the reputation of `assume()`](#45501 (comment)), this seems higher relevant. Here we try to see if commenting it out can fix the errors.

Later @alexcrichton has bisected and found a potential bug [in the LLVM side](#48116 (comment)). We are currently testing if reverting that LLVM commit is enough to stop the bug. If true, this PR can be reverted (keep the `assume()`) and we could backport the LLVM patch instead.

(This PR also includes an earlier commit from #48127 for help debugging ICE happening in compile-fail/parse-fail tests.)

The PR also reverts #48059, which seems to cause #48192.

r? @alexcrichton
cc @eddyb, @arthurprs (#47333)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants