Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle panic while converting to Duration #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

undali
Copy link
Contributor

@undali undali commented Jun 7, 2023

To resolve #18

@@ -157,7 +158,7 @@ pub fn from_str_at_date(date: NaiveDate, s: &str) -> Result<Duration, ParseDurat
is_ago = true;
}

let duration = match unit {
let duration = panic::catch_unwind(|| match unit {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is too broad

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably second only

Copy link
Contributor Author

@undali undali Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, did you mean to catch panic only for case Duration::seconds ?
But it seems 8 out of the 11 case can cause panic when called with very high value.

One more thing, Should I remove the test case? It causes test failure in Basic:CI probably because of the option RUSTDOCFLAGS: -Cpanic=abort.

Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@undali sorry but thinking more about this, it should probably done at the chrono level directly.
They should probably not panic when hitting this error

@tertsdiepraam
Copy link
Member

I agree with Sylvestre. chrono is working on removing at lot of panics and making their functions more fallible. See for instance: chronotope/chrono#815 and chronotope/chrono#1049.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fuzzing: thread 'main' panicked at 'Duration::seconds out of bounds'
3 participants