-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Make tests pass in 2038 #927
base: master
Are you sure you want to change the base?
Conversation
hah brilliant! I was probably putting this off until at least 2030. I was suspecting this to break in more places, so I'll have to double check the reltime stuff. The expiration time in actual items is 32bit (and I can't expand that to 64bit), but since it's relative it means you can set exptimes like 60 years in the future which should be fine... looking at it quickly, in not clear if that's a bug yet though.... |
should we add clamping code there to ensure that setting an expiry 100 years in the future just sets its to the max value 0x7fffffff (68y)? |
I think so yeah. need to be careful since the realtime() function's in a couple hot paths. |
https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html could help. Since 30+ years, x86 CPUs have features to report if overflow happened with little performance impact. |
I've been careful of these types of extensions because of the various risc ports. I won't have time to do some in-depth research for a couple weeks but if you or someone wants to propose something portable that'd be super |
I added a 3rd commit with an overflow check. The compiler (gcc+clang) should ensure However, I did not really understand the meaning of
|
If you could add some tests for expiry in +100y, -100y and such, I could run them with these patches. |
I'll try to explain some of the idioms here:
This essentially gives us a sliding window for expirations instead of a strict 2038 bug; though I never specifically tested 2038. It also means + or - 100 years will never work as a test, as the internal TTL stays 32bit. It also means the time limit is essentially "the total uptime of the system + how far into the future you're setting TTL's". |
For that we parse exptime as 64-bit int to avoid errors in t/expirations.t and t/flush-all.t
that had potential for problems with new 64-bit timestamps
I rebased the patch to make it easier to read now that #934 is merged. |
Thanks for that! sorry this is taking so long to validate and merge. My users are all highly conservative so I need to make sure I have dedicated enough time to validation. |
see individual commit messages for details
Background:
As part of my work on reproducible builds for openSUSE, I check that software still gives identical build results in the future.
The usual offset is +16 years, because that is how long I expect some software will be used in some places.
This showed up failing tests in our package build.
btw: there might be more work needed, but at least tests passed without this