Skip to content

Debug Assertions Triggered In gix-blame #1847

Closed
@holodorum

Description

@holodorum

Current behavior 😯

Last week I was playing around with gix blame recently upgraded by @cruessler.
I've made a clone of the linux repository and ran the following script to get the blame for CREDITS.

use gitoxide_core::repository::blame::blame_file;

fn main() -> anyhow::Result<()> {
    // Set repository and file to read
    let repo = gix::discover("./tmp/linux/").unwrap();
    let file = OsStr::new("CREDITS");

    let out = std::fs::File::create("./tmp/out.txt")?;
    blame_file(repo, file, None, &mut std::io::BufWriter::new(out), Some(&mut std::io::stdout()))?;

    Ok(())
}

The program hits one of the debug assertions with the following output:


❯ RUST_BACKTRACE=1 cargo run --bin bug_blame
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.30s
     Running `target/debug/bug_blame`
thread 'main' panicked at /xxxxx/gitoxide/gix-blame/src/file/function.rs:301:25:
#[
    UnblamedHunk {
        range_in_blamed_file: 0..22,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 0..22,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 26..191,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 22..187,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 196..282,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 187..273,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 282..389,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 273..380,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 392..544,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 380..532,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 551..585,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 532..566,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 588..820,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 566..798,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 825..1218,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 798..1191,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1222..1247,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1191..1216,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1251..1376,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1216..1341,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1376..1434,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1345..1403,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1438..1695,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1403..1660,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1695..1709,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1665..1679,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1714..1822,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1679..1787,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1826..1893,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1787..1854,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1897..1898,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1854..1855,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 1901..2213,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 1855..2167,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 2213..3181,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 2180..3148,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 3187..3204,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 3148..3165,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 3209..3317,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 3165..3273,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 3321..3598,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 3273..3550,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 3598..3787,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 3555..3744,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 3792..3817,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 3744..3769,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 3821..4311,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 3769..4259,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 4315..4415,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 4259..4359,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 4415..4416,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 4359..4360,
        },
    },
    UnblamedHunk {
        range_in_blamed_file: 4419..4464,
        suspects: {
            Sha1(4cece764965020c22cff7665b18a012006359095): 4359..4404,
        },
    },
]
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/panicking.rs:76:14
   2: gix_blame::file::function::file
             at ./gix-blame/src/file/function.rs:301:25
   3: gitoxide_core::repository::blame::blame_file
             at ./gitoxide-core/src/repository/blame.rs:41:19
   4: bug_blame::main
             at ./src/bin/bug_blame.rs:11:5
   5: core::ops::function::FnOnce::call_once
             at /xxx/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected behavior 🤔

Running the same code on the README file returns without errors.

Git behavior

No response

Steps to reproduce 🕹

No response

Metadata

Metadata

Assignees

Labels

acknowledgedan issue is accepted as shortcoming to be fixed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions