GitoxideLabs / gitoxide

An idiomatic, lean, fast & safe pure Rust implementation of Git
Apache License 2.0
8.91k stars 303 forks source link

reproduce and fix date fuzz error #1488

Closed Byron closed 2 months ago

Byron commented 2 months ago

Reproduce a fuzz failure.

Fortunately it's just an incorrect expectation.

Tasks

Byron commented 2 months ago

I thought you'd find this interesting, @BurntSushi , as this is an expectation failure.

date is in range: Error { inner: ErrorInner { kind: Adhoc(error converting datetime -009999-01-01T00:00:00 to instant in time zone UTC), cause: Some(Error { inner: ErrorInner { kind: Range(RangeError(Negative { what: "second", given: 0, min: -377705023201, max: 253402207200 })), cause: None } }) } }
thread 'time::parse::fuzz::invalid_but_does_not_cause_panic' panicked at gix-date/src/parse.rs:36:51:

Probably that's just a mistake and the fix is as easy as it looks, but I'd be glad if you would let me know. Thank you.

BurntSushi commented 2 months ago

Yup that is indeed an expected error! Nice find fuzzer. I think I used expect() here because that's what it did previously with time, but indeed, this should be an error. (time I believe supports a bigger range than Jiff does.)

For why this happens, Jiff guarantees that every Timestamp can be converted to a civil::DateTime, but sacrifices the opposite direction at the boundaries. The error cases in this example might help make this clearer. (The example uses DateTime::MAX instead of DateTime::MIN, but it's the same idea.)