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

uint overflow #190

Open
jujing opened this issue Aug 31, 2015 · 3 comments
Open

uint overflow #190

jujing opened this issue Aug 31, 2015 · 3 comments
Labels

Comments

@jujing
Copy link

jujing commented Aug 31, 2015

In /Server/StateMachine.cc, function StateMachine::shouldTakeSnapshot, line 599 (version: 1.1.0)
uint64_t curr = 0;
if (lastIncludedIndex > stats.last_snapshot_index())
curr = lastIncludedIndex - stats.last_snapshot_index();
uint64_t prev = curr - 1;

Subtract operation overflows on operands "curr" and "1UL", whose values are unsigned constants, 0 and 1, respectively.

@ongardie
Copy link
Member

That logic around that log message is a bit odd and probably doesn't do the right thing in all cases. @jujing, do you want to contribute a small patch or pull request for this? I think anything that avoids the underflow would be an improvement.

@ongardie ongardie added the bug label Aug 31, 2015
@jujing
Copy link
Author

jujing commented Sep 2, 2015

I wish to do that. But in my working environment, there are some limitations to prohibit me to commit code to github. And I only have a pad at home. I should solve the problem first.
For this issue, I think a simple way to avoid the underflow is that change the type of variables curr, prev, logEntries from uint64_t to int64_t.

@ongardie
Copy link
Member

Ah. And I'm waiting permission from legal to write code...

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

No branches or pull requests

2 participants