Skip to content

Failure on attempt to serialize a pre-epoch timestamp received from an ext3 filesystem #464

@ssokolow

Description

@ssokolow

While working on a tool to index files for one of my projects, I wound up getting a panic during the call to serde_json:

thread 'main' panicked at 'SystemTime must be later than UNIX_EPOCH: SystemTimeError(Duration { secs: 1, nanos: 0 })', libcore/result.rs:945:5

I tracked it down to a specific file in my home media server. Apparently, the combination of Linux and the ext3 filesystem is perfectly capable of representing at least one date before the UNIX epoch.

  • ls -lh: Dec 31 1969
  • Python's os.stat: st_mtime=-1
  • Rust's std::fs::metadata: modified: Ok(SystemTime { tv_sec: -1, tv_nsec: 0 })

...and the irony is, SystemTime is the one piece of the Rust-provided metadata that I felt was already in a format suitable for a generic index file to be shared between programs written in different languages.

Well... that and it was a hassle to track down because Rust itself didn't complain and the panic message during serialization wouldn't tell me which file of the hundreds of thousands was causing it to die. For lack of a purpose-built tool, I had to manually bisect it until I narrowed it down.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions