-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-incr-compArea: Incremental compilationArea: Incremental compilationC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityCritical 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.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Milestone
Description
PR #86475 introduced a global cache for vtable-layouts into the tcx
which circumvents incremental compilation's dependency tracking. The effect is that object files might not get updated when methods within a trait get shuffled around, thus leading to miscompilations very similar to the one observed in #82920, i.e. trait object method calls will invoke the wrong method.
The following test (when added to src/test/incremental
) shows this behavior:
// revisions:rpass1 rpass2
trait Foo {
#[cfg(rpass1)]
fn method1(&self) -> u32;
fn method2(&self) -> u32;
#[cfg(rpass2)]
fn method1(&self) -> u32;
}
impl Foo for u32 {
fn method1(&self) -> u32 { 17 }
fn method2(&self) -> u32 { 42 }
}
fn main() {
let x: &dyn Foo = &0u32;
// This fails in `rpass2` because `method2` gets called instead of `method1`.
assert_eq!(mod1::foo(x), 17);
}
mod mod1 {
pub fn foo(x: &dyn super::Foo) -> u32 {
x.method1()
}
}
Global caches without dependency tracking are a sure way of introducing subtle incr. comp. bugs. Queries must be used instead.
I'm going to mark this as P-critical
. We should fix this asap.
Metadata
Metadata
Assignees
Labels
A-incr-compArea: Incremental compilationArea: Incremental compilationC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityCritical 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.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.