{"action":"created","issue":{"url":"https://api.github.com/repos/serde-rs/json/issues/464","repository_url":"https://api.github.com/repos/serde-rs/json","labels_url":"https://api.github.com/repos/serde-rs/json/issues/464/labels{/name}","comments_url":"https://api.github.com/repos/serde-rs/json/issues/464/comments","events_url":"https://api.github.com/repos/serde-rs/json/issues/464/events","html_url":"https://github.com/serde-rs/json/issues/464","id":341897652,"node_id":"MDU6SXNzdWUzNDE4OTc2NTI=","number":464,"title":"Panic on attempt to serialize a pre-epoch timestamp received from an ext3 filesystem","user":{"login":"ssokolow","id":46915,"node_id":"MDQ6VXNlcjQ2OTE1","avatar_url":"https://avatars3.githubusercontent.com/u/46915?v=4","gravatar_id":"","url":"https://api.github.com/users/ssokolow","html_url":"https://github.com/ssokolow","followers_url":"https://api.github.com/users/ssokolow/followers","following_url":"https://api.github.com/users/ssokolow/following{/other_user}","gists_url":"https://api.github.com/users/ssokolow/gists{/gist_id}","starred_url":"https://api.github.com/users/ssokolow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssokolow/subscriptions","organizations_url":"https://api.github.com/users/ssokolow/orgs","repos_url":"https://api.github.com/users/ssokolow/repos","events_url":"https://api.github.com/users/ssokolow/events{/privacy}","received_events_url":"https://api.github.com/users/ssokolow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-07-17T12:28:19Z","updated_at":"2018-07-19T11:12:06Z","closed_at":null,"author_association":"NONE","body":"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`:\r\n\r\n    thread 'main' panicked at 'SystemTime must be later than UNIX_EPOCH: SystemTimeError(Duration { secs: 1, nanos: 0 })', libcore/result.rs:945:5\r\n\r\nI 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.\r\n\r\n* `ls -lh`: `Dec 31  1969`\r\n* Python's `os.stat`: `st_mtime=-1`\r\n* Rust's `std::fs::metadata`: `modified: Ok(SystemTime { tv_sec: -1, tv_nsec: 0 })`\r\n\r\n...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.\r\n\r\nWell... 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."},"comment":{"url":"https://api.github.com/repos/serde-rs/json/issues/comments/406241034","html_url":"https://github.com/serde-rs/json/issues/464#issuecomment-406241034","issue_url":"https://api.github.com/repos/serde-rs/json/issues/464","id":406241034,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjI0MTAzNA==","user":{"login":"lambda","id":37398,"node_id":"MDQ6VXNlcjM3Mzk4","avatar_url":"https://avatars2.githubusercontent.com/u/37398?v=4","gravatar_id":"","url":"https://api.github.com/users/lambda","html_url":"https://github.com/lambda","followers_url":"https://api.github.com/users/lambda/followers","following_url":"https://api.github.com/users/lambda/following{/other_user}","gists_url":"https://api.github.com/users/lambda/gists{/gist_id}","starred_url":"https://api.github.com/users/lambda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lambda/subscriptions","organizations_url":"https://api.github.com/users/lambda/orgs","repos_url":"https://api.github.com/users/lambda/repos","events_url":"https://api.github.com/users/lambda/events{/privacy}","received_events_url":"https://api.github.com/users/lambda/received_events","type":"User","site_admin":false},"created_at":"2018-07-19T11:12:06Z","updated_at":"2018-07-19T11:12:06Z","author_association":"NONE","body":"Yep, I figured that out after writing the previous comment, and started working on a patch to serde to fix it.\r\n\r\nMy main concern is that `i128` was only fairly recently stabilized, so would require bumping the minimum required version of the compiler.  Also, even if you made the implementation conditional on `i128` support, it would be a breaking change for `Serializer` and `Deserializer` implementations that don't yet have `i128` support.\r\n\r\nSo I think you'd have to do it without `i128` for `secs_since_epoch`, which makes it more complicated. On Unix like platforms and Redox, it's at most an `i64` number of seconds offset from the epoch. On Windows, it's a `u64` number of nanoseconds since January 1, 1601, which has a strictly lower range than an `i64`number of seconds, so that should be OK. But on WASM, they just use a `Duration` to represent the time since the epoch, so you actually could have the full `u64` range that you need to be able to represent.\r\n\r\nI think that you'll just have to use an `i64` here, and consider the loss of one bit of range on the top end to be preferable to not being able to represent negative values, which are likely to be more common."}}
{"actor":{"display_login":"lambda"}}