Skip to content

Trait objects missing #[track_caller] shims #74764

Closed
@anp

Description

@anp

After reducing a repro of a potential track_caller bug from @yaahc, I get a segfault from this code:

trait Handler {
    fn handle(&self);
}

impl<T> Handler for T {
    #[track_caller]
    fn handle(&self) {
        assert_eq!(std::panic::Location::caller().file(), file!());
    }
}

fn main() {
    let handler: &(dyn Handler) = &5u8;
    handler.handle();
}

This repros for me on my up-to-date checkout as well as for the current beta compiler. I'm not sure whether that makes this a regression from stable to beta, since it's an apparent bug in an API which is first stabilizing in this release.

cc @eddyb

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-track_caller`#![feature(track_caller)]`I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions