rust-analyzer: New weekly build crashs reproducily

I’ve doing some work on diesel. Pointing with the cursor to this line reproducibly crashes rust-analyzer with the attached backtrace.

Version: rust-analyzer 90f8378 OS: Ubuntu 20.04 IDE: Emacs

Backtrace: 
thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 7', /home/runner/.cargo/git/checkouts/chalk-7b02fa8caa2cec94/28cef6f/chalk-ir/src/fold/subst.rs:56:19
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
  19: <unknown>
  20: <unknown>
  21: <unknown>
  22: <unknown>
  23: <unknown>
  24: <unknown>
  25: <unknown>
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: <unknown>
  30: <unknown>
  31: <unknown>
  32: <unknown>
  33: <unknown>
  34: <unknown>
  35: <unknown>
  36: <unknown>
  37: <unknown>
  38: <unknown>
  39: <unknown>
  40: <unknown>
  41: <unknown>
  42: <unknown>
  43: <unknown>
  44: <unknown>
  45: <unknown>
  46: <unknown>
  47: <unknown>
  48: <unknown>
  49: <unknown>
  50: <unknown>
  51: <unknown>
  52: <unknown>
  53: <unknown>
  54: <unknown>
  55: <unknown>
  56: <unknown>
  57: <unknown>
  58: <unknown>
  59: <unknown>
  60: <unknown>
  61: <unknown>
  62: <unknown>
  63: <unknown>
  64: <unknown>
  65: <unknown>
  66: <unknown>
  67: <unknown>
  68: <unknown>
  69: <unknown>
  70: <unknown>
  71: <unknown>
  72: <unknown>
  73: <unknown>
  74: <unknown>
  75: <unknown>
  76: <unknown>
  77: <unknown>
  78: <unknown>
  79: <unknown>
  80: <unknown>
  81: <unknown>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 23 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Small guide to minimizing the reproducer for such a crash, in case someone is interested:

  • we know the function that crashes RA already, and indeed rust-analyzer analysis-stats -o internal_into_boxed . causes the crash; otherwise I’d see where the progress bar says we are and hope that’s the right function
  • I removed the other impls of internal_into_boxed so they don’t interfere, and checked that it still crashes
  • then, since I suspected the dyn type, I commented out the where clause involving the dyn, and indeed then the crash is gone
  • then I just commented out various groups of lines to see whether it still crashes - we can remove all the other where clauses, actually, and only need the self.order.into(); call (keep in mind that we don’t need the result to type-check, just to crash in the same way…)
  • then I replaced some names by non-existing ones to see whether it’s necessary that they resolve, and removed the Options and Boxes
  • then I copied the definitions of the remaining types next to the impl, and simplified them a bit as well
  • and I kept removing things to simplify.

In the end I ended up with:

trait BoxedDsl<DB> {
    type Output;
    fn internal_into_boxed(self) -> Self::Output;
}

struct SelectStatement<From, Select, Distinct, Where, Order, LimitOffset, GroupBy, Locking> {
    order: Order,
}

trait QueryFragment<DB: Backend> {}

trait Into<T> { fn into(self) -> T; }

impl<F, S, D, W, O, LOf, DB> BoxedDsl<DB>
    for SelectStatement<F, S, D, W, O, LOf, G>
where
    O: Into<dyn QueryFragment<DB>>,
{
    type Output = XXX;

    fn internal_into_boxed(self) -> Self::Output {
        self.order.into();
    }
}

and copied that to a test, where it indeed still crashed. With that, finding and fixing the bug was just a matter of some print debugging 😉

That’s where @edwin0cheng’s page gets its test cases from, IIRC 😄

Actually, diesel would be a good example. I’ll add it to CI, once we stop crashing on it.

Hm, actually, why re-invent the wheel? We should just re-use https://github.com/rust-lang/rustc-perf/tree/master/collector/benchmarks

Yeah, either cargo build --release from source (you really need the release build), or download a nightly build from our releases.

if !nightly {

Ah, so that wasn’t a Deja vu 😃

but I can’t find that in the workflows.

That’s in dist.rs

What would you say about enabling debug info for nightly builds?

Yes 😃