Repository navigation
Closed
Closed
Copy link
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Description
EDITED: MCVE is here: #67684 (comment)
I received this compiler bug:
sand:mesa_x dpp$ cargo test
Compiling mesa_x v0.1.0 (/Users/dpp/proj/mesa_x)
error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:42: could not fully normalize `fn() -> <impl combine::Parser as combine::Parser>::PartialState {<<impl combine::Parser as combine::Parser>::PartialState as std::default::Default>::default}`
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:931:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
note: the compiler unexpectedly panicked. this is a bug.
Compiling with this cargo.toml file:
[package]
name = "mesa_x"
version = "0.1.0"
authors = ["David Pollak <feeder.of.the.bears@gmail.com>"]
edition = "2018"
[dependencies]
# nom = "5.0.1"
combine = "3.8.1"
And this main.rs:
#[macro_use]
extern crate combine;
use combine::parser::char::{alpha_num, char, digit, letter, spaces};
use combine::stream::{Stream};
use combine::{
between, choice, attempt, easy,
many, many1, none_of, optional, parser, sep_by, Parser,
};
#[derive(Debug, PartialEq)]
pub struct Address {}
#[derive(Debug, PartialEq)]
pub enum Range {}
#[derive(Debug, PartialEq)]
pub enum Function {}
#[derive(Debug, PartialEq)]
pub enum Expression {
Int(i128),
Float(f64),
Str(String),
Identifier(String),
Address(Address),
Range(Range),
Function(String, Vec<Expression>),
Infix(Function, Box<Expression>, Box<Expression>),
Expression(Box<Expression>),
}
// `impl Parser` can be used to create reusable parsers with zero overhead
fn expr_<I>() -> impl Parser<Input = I, Output = Expression>
where
I: Stream<Item = char, Error = easy::ParseError<I>>,
// Necessary due to rust-lang/rust#24159
// I::Error: ParseError<I::Item, I::Range, I::Position>,
{
let int2 = between(optional(spaces()), optional(spaces()), (optional(char('-')), many1(digit())))
.and_then(|(sign, s): (Option<char>, String)| {
match (sign, s.parse::<i128>()) {
(Some('-'), Ok(r)) => Ok(Expression::Int(r * -1i128)),
(_, Ok(r)) => Ok(Expression::Int(r)),
(_, Err(_x)) => Err(easy::Error::Expected(easy::Info::Borrowed("combine"))),
}
});
let string = between(
(optional(spaces()), char('"')),
(char('"'), optional(spaces())),
many(none_of("\"".chars())),
)
.map(|s| Expression::Str(s));
let identifier = (spaces(), letter(), many(alpha_num()))
.map(|(_, c, st): ((), char, String)| c.to_string() + &st);
let identifier2 = (spaces(), letter(), many(alpha_num()), spaces())
.map(|(_, c, st, _): ((), char, String, ())| Expression::Identifier(c.to_string() + &st));
let comma_list = sep_by(expr(), (optional(spaces()), char(','), optional(spaces()))).map(|v: Vec<Expression>| v);
let function = (
identifier,
between(char('('),
char(')'), comma_list)
)
.map(|(id, exprs)| Expression::Function(id, exprs));
choice((attempt(function), attempt(identifier2), attempt(string), attempt(int2))) //.skip_spaces()
}
parser! {
fn expr[I]()(I) -> Expression
where [I: Stream<Item = char, Error = easy::ParseError<I>>]
{
expr_()
}
}
#[test]
fn test_parsing() {
let test_exprs = vec![
r#"147"#,
r#""Hello World""#,
r#"true"#,
r#"if(32, "yes", "no")"#,
r#"if(true, "yes", "no")"#,
r#" "Hello World""#,
r#"-32"#,
r#"32.99"#,
r#"-32.822"#,
//r#"SuM(a1:$B7)"#,
//r#"3 + 39"#,
//r#"IF(a1, SUM(a1:$b$7), 3 + 39)"#,
];
for item in test_exprs {
match expr().easy_parse(item) {
Ok((_x, "")) => {
//println!("Got {:#?}", x);
assert!(true)},
Ok((_, x)) => assert!(
false,
format!("Failed to parse whole thing... remaining '{}'", x)
),
Err(x) => assert!(false, format!("Trying '{}', got Error {:#?}", item, x)),
}
}
}
fn main() {
println!("Hello, world!");
}
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Activity
Centril commentedon Dec 28, 2019
If possible, a self-contained reproducer in the playground would be quite helpful towards fixing the bug.
dpp commentedon Dec 28, 2019
@Centril -- I tried, but the
combinecrate is not a default crate on the playground. How can I add a crate to a playground page? Sorry for the n00b questionCentril commentedon Dec 29, 2019
@dpp You can't. What I would do is inline the pieces you need from
combineinto your local crate until you can reproduce the issue withoutcombine. Once you've done that, it's a good idea to start minimizing (but once we have a playground link it gets easier to help).dpp commentedon Dec 29, 2019
🙄
Okay... y'all have a bug that causes the compiler to panic. This is suboptimal in a language that is supposed to make guarantees about this kinda thing. But okay... there's a panic in the compiler.
Me... a Rust n00b, but a person who's been doing open source for 29 years and have my share
of non-trivial projects... I get that asking folks to help out and filing bugs in a uniform way.
But you've just asked me to copy/paste 13,000 LoC into the playground and nibble away at the
problem so I have a minimally reproducible example... because it's too difficult for the compiler
team that should pride itself on having zero panics to create a new project and copy/paste
the Cargo.toml and main.rs code from the bug .
Not real welcoming.
csmoe commentedon Dec 30, 2019
@dpp I think there’s some misunderstanding here:
as @Centril wrote, he was just trying to guide you to create a mcve. If time is tough for you, just leave this ICE here, mvce of an ICE is not a must from the original reporter, people from the community will pick this up to minimize as the
E-needs-mvcelabel was already added.And thanks for your reporting :)
Centril commentedon Jan 2, 2020
ICE occurs in:
rust/src/librustc_traits/normalize_erasing_regions.rs
Line 34 in 0a58f58
pnkfelix commentedon Jan 2, 2020
triage P-high, at least to learn more about the nature of this bug itself (e.g. getting the MCVE, and/or a stack trace...)
5 remaining items
fanninpm commentedon May 12, 2020
Curiously, I can't get the latest MVCE to ICE on the latest nightly for Mac, even though it ICEs just fine on the playground.
asomers commentedon Sep 8, 2020
I am reliably hitting this ICE with nightly-2020-09-07-x86_64-unknown-freebsd, but not with nightly-2020-08-28-x86_64-unknown-freebsd. Unfortunately, I'm hitting it in a large application that only builds on FreeBSD, so my odds of reducing it to a slim test case are slim. But it looks like the same error as in the playground link above.
Workaround Rust ICE in CI
fanninpm commentedon Dec 17, 2020
@dpp You may be interested in how @chengniansun uses Perses.
chengniansun commentedon Dec 17, 2020
Further reduced with perses.
Stack trace
Add 67684
Add 67684