-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Large integers get truncated #594
Comments
|
@daohu527 Signed overflow is undefined behavior in C++, and the type here is an |
LOG_EVERY_NThey use two parameters to implement this logic. LOG_OCCURRENCES_MOD_N will not great than N+1 to filter the log. And LOG_OCCURRENCES will use to count the log num. Lines 908 to 915 in c8f8135
So I said there is no problem with logic, LOG_OCCURRENCES int will overflow is true, but LOG_OCCURRENCES_MOD_N not. |
In our application we have some loggers that trigger every millisecond.
This is problematic since
LogMessage
uses a signed 32-bit integer as the counter type (see here) which can lead to a wrap every 24.85. This is bad for long-running processes.It would probably be better if
LogMessage
useduint64_t
orsize_t
as the counter type.If there's a size concern, then using
uint32
as the data type would at least double the time before wrap around.The text was updated successfully, but these errors were encountered: