-
Notifications
You must be signed in to change notification settings - Fork 7
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
Replace chrono with time (address RUSTSEC-2020-0071) #6
base: main
Are you sure you want to change the base?
Conversation
@kevinhoffman is there anything blocking this from being merged and released? Would be happy to help if I can. |
Bump? |
Any update on this @kevinhoffman? Would be awesome to have this so we can use this crate in projects where we enforce |
I want to ➕ what others' have been asking for: any update on getting this merged? |
@@ -313,8 +308,8 @@ where | |||
RC: RollingCondition, | |||
{ | |||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { | |||
let now = Local::now(); | |||
self.write_with_datetime(buf, &now) | |||
let now = OffsetDateTime::now_local().unwrap_or_else(|_| OffsetDateTime::now_utc()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: This change can introduce a memory leak due to time-rs/time#651
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A mach ports leak is better than a segfault, but this is something best addressed via a PR to the num_threads
crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called quite frequently and every call will leak at least numberOfThreads
mach ports. This can easily accumulate to several GB of leaked memory for long-running processes like daemons.
It's also worth pointing out that OffsetDateTime::now_local()
will always fail for macOS (unless the process is single threaded). Which makes this equivalent to let now = OffsetDateTime::now_utc();
(on Apple platforms).
It might make sense to consider rotating based on UTC instead of local time in general. This would save quite a few CPU cycles and it's what would happen on Apple platforms with the suggested code anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think rotating on UTC is a totally acceptable solution. I'm happy to modify the PR, but I haven't heard anything from the maintainer in over a year so I'm not sure if the crate is still being maintained.
Out of curiosity. Since version 0.4.30 chrono no longer depends on time 0.1 (https://github.com/chronotope/chrono/releases/tag/v0.4.30). And before that it didn't use the code that was vulnerable to RUSTSEC-2020-0071 since chrono 4.20. |
This library is unfortunately more susceptible than normal to the env var race conditions in the RUSTSEC, because it uses local time calls extensively.
This PR addresses the vulnerability by replacing
chrono
withtime 0.3
. This is a semver breaking change, because it touches quite a few public interfaces.