-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix g_time3() overflow #1087
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
base: devel
Are you sure you want to change the base?
Fix g_time3() overflow #1087
Conversation
|
I think in tests/common/os_calls/g_time.c, before include os_calls.h you need to include config_ac.h |
|
Indeed, thanks. |
|
Fixed Travis CI. |
38e3e52 to
7149a06
Compare
|
i'm not sure about that change. while it "solves" the truncation issue its not precise enough. while we shall count seconds using anyhow i'm not sure if we care about the resolution anywhere. |
|
Please note We already using |
|
About the PR itself, i'm ok. |
i don't think you should return non primitive type from |
|
@metalefty The timex() functions are returning a time val in mssec or sec that is used to compare to a later call to timex() or just to log a time value. Also the names are just ugly. Free free to name new functions that can be accurate and return uint64_t if that is better. We can depreciate these. |
in common/os_calls.c.
signed int causes overflow since it returns epoch time in msec.
7149a06 to
e525cc5
Compare
|
Just came across this one. I think I addressed all of this in #3328. Lines 410 to 427 in aac4946
Does that cover everything, or have I missed something? |
|
Thanks. It's been a long time so I don't remember that g_time3() overflow affects what. g_get_elapsed_ms() is not in v0.10 but I'm fine with closing this if the overflow in v0.10 is not severe. |
|
The changes I made in #3228 for g_get_elapsed_ms() :-
For v0.10.x we're using signed values. Overflow of these is implementation-defined. We've had no reports of any problems in v0.10, so in practice I think we're OK. The other big change in #3228 was removing |
CC: @moobyfr
g_time3() returns epoch time in msec. However, return type is int. The maximum value of signed int is 2147483647. Current epoch time is around 1522431329. Only 30% room remained. epoch time * 1000 overflows. To handle epoch time in msec properly, the container should have 64 bit size.
First of all, I made a test for g_time*() function.
How to test:
Expected
Actual
Fix
g_time*() should be
long long. I'll make a fix in addition to this PR branch. Please review the test code first.