Closed
Description
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.
struct R { }
fn f() {
R
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
- regressed nightly: nightly-2022-10-21
- regressed commit: 53728ff (PR Fix the bug of next_point in source_map #103185)
@rustbot label +regression-from-stable-to-nightly +I-hang