-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compile won't finish for ever with dynamic. #84102
Comments
Compilation terminates on 1.46 with an error:
@rustbot label I-hang regression-from-stable-to-stable |
I've managed to reduce the example code significantly, while still triggering what I believe to be a root issue. pub trait Wrapable {
fn dyn_wrap(self) -> Box<dyn Wrapable>;
}
pub struct DynWrapper(pub Box<dyn Wrapable>);
pub struct Wrapper<T>(T);
impl<T: 'static> Wrapable for Wrapper<T> {
fn dyn_wrap(self) -> Box<dyn Wrapable> {
Box::new(Wrapper(self))
}
}
fn main() {
DynWrapper(Box::new(Wrapper(())));
} The error is now about recursion limit while performing drop check.
In order to get back to the original issue (compilation not terminating in reasonable time), more generic arguments have to be added to the Then compiler seems to be generating permutations of those impls with infinite depth. Looks like those permutations are causing way slower approach to the depth limit, thus making the compilation not terminate quickly. |
Using this slight reduction, which still hangs: use std::sync::Arc;
pub trait Symbol: 'static {
fn diff_dyn(&self) -> Arc<dyn Symbol> {
unimplemented!()
}
}
impl Symbol for Arc<dyn Symbol> {}
#[derive(Clone)]
pub struct Variable;
impl Symbol for Variable {}
pub struct DynExpr(pub Arc<dyn Symbol>);
pub struct BinarySym<Op, Sym1, Sym2> {
_op: Op,
sym1: Sym1,
sym2: Sym2,
}
impl<Op, Sym1, Sym2> BinarySym<Op, Sym1, Sym2> {
pub fn new(_sym1: Sym1, _sym2: Sym2) -> Self {
unimplemented!()
}
}
impl<Op, Sym1, Sym2> Clone for BinarySym<Op, Sym1, Sym2> {
fn clone(&self) -> Self {
unimplemented!()
}
}
pub struct MulOp;
pub type MulSym<Sym1, Sym2> = BinarySym<MulOp, Sym1, Sym2>;
impl<Sym1, Sym2> Symbol for MulSym<Sym1, Sym2>
where
Sym1: Symbol,
Sym2: Symbol,
{
}
pub struct DivOp;
pub type DivSym<Sym1, Sym2> = BinarySym<DivOp, Sym1, Sym2>;
impl<Sym1, Sym2> Symbol for DivSym<Sym1, Sym2>
where
Sym1: Symbol + Clone,
Sym2: Symbol + Clone,
{
fn diff_dyn(&self) -> Arc<dyn Symbol> {
Arc::new(DivSym::new(
MulSym::new(self.sym1.clone(), self.sym2.clone().diff_dyn()),
MulSym::new(self.sym2.clone(), self.sym2.clone()),
))
}
}
fn main() {
let _div = DynExpr(Arc::new(DivSym::new(Variable, Variable)));
} Bisected using a 30 second timeout: Regression in nightly-2020-09-19 found 8 bors merge commits in the specified range Of these, only #76837 and #72412 landed in 1.47 (as backports), which is the stable version that regressed. GDB backtrace of the hang
|
Assigning priority as discussed as part of the Prioritization Working Group procedure and removing @rustbot label -I-prioritize +P-medium |
This was fixed in #83406 |
Closing as fixed (backporting was suggested but it didn't happen while it was on nightly). |
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=02201e00b6564bb0149acccfdf698b9d
I expected to see this happen: Compiles or have some error.
Instead, this happened: Compile won't finish for ever. Commenting out the final line will make it work.
Meta
I tried in my environment and Rust Playground.
rustc --version --verbose
:Backtrace
I couldn't get the backtace.
With
cargo +nightly rustc --bin symbolic-diffs -- -Z time-passes
I got below.The text was updated successfully, but these errors were encountered: