This malformed code (playground) hangs the compiler:
struct R { }
struct S {
x: [u8; R
Found by fuzzing with a modified fuzz-rustc.
The bug's edges
R must be defined as a named-field struct (not a tuple struct or unit struct), although it can have 0 fields.
R must be the last token to produce the hang:
- No opening brace (note that braces are required for literals of named-field structs)
- No closing delimiters
- Not even a comment
Where it hangs
If I understand mj.sample.txt correctly, the hang occurs in LateResolutionVisitor, with try_lookup_name_relaxed never finishing (while calling various functions such as smart_resolve_context_dependent_help and span_to_snippet)
Additional example
This also hangs. I'm guessing it's the same bug.
Version
rustc --version --verbose:
rustc 1.66.0-nightly (6e95b6da8 2022-10-22)
binary: rustc
commit-hash: 6e95b6da885f42a4e1314595089fa4295e329d11
commit-date: 2022-10-22
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2
Regression
Bisected with:
cargo-bisect-rustc --start=2022-10-03 --end=nightly-2022-10-23 --preserve --script=./timeout.sh
timeout.sh
#!/bin/bash
# This script is wrong in several ways:
# - It will try to kill processes that might no longer exist
# - It may leave an orphan rustc process after the bisect (because it only kills the shell, not rustc)
# But it seems to be good enough for bisection to work
killall rustc
outershell=$$
(sleep 5; kill $outershell) &
rustc src/main.rs
true
@rustbot label +regression-from-stable-to-nightly +I-hang
This malformed code (playground) hangs the compiler:
Found by fuzzing with a modified fuzz-rustc.
The bug's edges
Rmust be defined as a named-field struct (not a tuple struct or unit struct), although it can have 0 fields.Rmust be the last token to produce the hang:Where it hangs
If I understand mj.sample.txt correctly, the hang occurs in LateResolutionVisitor, with
try_lookup_name_relaxednever finishing (while calling various functions such assmart_resolve_context_dependent_helpandspan_to_snippet)Additional example
This also hangs. I'm guessing it's the same bug.
Version
rustc --version --verbose:Regression
Bisected with:
timeout.sh
@rustbot label +regression-from-stable-to-nightly +I-hang