Skip to content

Miscompilation with incr. comp. #82920

Description

@jonas-schievink

I have pushed 2 commits that reproduce an incremental compilation bug that leads to a segmentation fault or countless test failures due to out-of-bounds panics:

Steps to reproduce:

First commit, then second:

$ git checkout 958af09d656289d7fe5c01f46c159f7859dd0901
$ cargo test -p ide_completion
<a few tests fail, because the code has a legitimate bug>
$ git checkout 6802a06a824164ff3e274a6bb638c4243cdec654
$ cargo test -p ide_completion
<many more tests fail with "index out of bounds" panics>
$ cargo clean
$ cargo test -p ide_completion
<tests pass>

Second commit, then first:

$ git checkout 6802a06a824164ff3e274a6bb638c4243cdec654
$ cargo test -p ide_completion
<tests pass>
$ git checkout 958af09d656289d7fe5c01f46c159f7859dd0901
$ cargo test -p ide_completion
   Compiling hir_ty v0.0.0 (/home/jonas/dev/rust-analyzer/crates/hir_ty)
   Compiling hir v0.0.0 (/home/jonas/dev/rust-analyzer/crates/hir)
   Compiling ide_db v0.0.0 (/home/jonas/dev/rust-analyzer/crates/ide_db)
   Compiling ide_completion v0.0.0 (/home/jonas/dev/rust-analyzer/crates/ide_completion)
    Finished test [unoptimized] target(s) in 13.15s
     Running unittests (target/debug/deps/ide_completion-68e02c0059fb642f)

running 243 tests
test completions::attribute::tests::no_completion_for_incorrect_derive ... ok
test completions::attribute::tests::test_attribute_completion_inside_nested_attr ... ok
test completions::dot::tests::test_completion_works_in_consts ... FAILED
test completions::dot::tests::test_tuple_field_completion ... FAILED
test completions::attribute::tests::test_attribute_completion ... ok
test completions::attribute::tests::test_inner_attribute_completion ... ok
test completions::dot::tests::test_no_struct_field_completion_for_method_call ... FAILED
test completions::attribute::tests::derive_with_input_completion ... ok
test completions::dot::tests::test_struct_field_and_method_completion ... FAILED
test completions::dot::tests::test_trait_method_completion ... FAILED
test completions::dot::tests::test_trait_method_completion_deduplicated ... FAILED
test completions::dot::tests::test_struct_field_completion_self ... FAILED
test completions::dot::tests::test_no_non_self_method ... FAILED
test completions::dot::tests::completes_trait_method_from_other_module ... FAILED
test completions::dot::tests::test_method_completion_issue_3547 ... FAILED
test completions::dot::tests::test_method_completion_only_fitting_impls ... FAILED
test completions::dot::tests::test_visibility_filtering ... FAILED
error: test failed, to rerun pass '-p ide_completion --lib'

Caused by:
  process didn't exit successfully: `/home/jonas/dev/rust-analyzer/target/debug/deps/ide_completion-68e02c0059fb642f` (signal: 11, SIGSEGV: invalid memory reference)
$ cargo clean
$ cargo test -p ide_completion
<a few tests fail, because the code has a legitimate bug>

This reproduces both on stable 1.50.0, as well as rustc 1.52.0-nightly (234781a 2021-03-07).

Apologies in advance for the nightmare that reducing this bug will probably be.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-incr-compArea: Incremental compilationC-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions