{"action":"created","issue":{"url":"https://api.github.com/repos/logcabin/logcabin/issues/190","labels_url":"https://api.github.com/repos/logcabin/logcabin/issues/190/labels{/name}","comments_url":"https://api.github.com/repos/logcabin/logcabin/issues/190/comments","events_url":"https://api.github.com/repos/logcabin/logcabin/issues/190/events","html_url":"https://github.com/logcabin/logcabin/issues/190","id":104041634,"number":190,"title":"uint overflow","user":{"login":"jujing","id":13994277,"avatar_url":"https://avatars.githubusercontent.com/u/13994277?v=3","gravatar_id":"","url":"https://api.github.com/users/jujing","html_url":"https://github.com/jujing","followers_url":"https://api.github.com/users/jujing/followers","following_url":"https://api.github.com/users/jujing/following{/other_user}","gists_url":"https://api.github.com/users/jujing/gists{/gist_id}","starred_url":"https://api.github.com/users/jujing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jujing/subscriptions","organizations_url":"https://api.github.com/users/jujing/orgs","repos_url":"https://api.github.com/users/jujing/repos","events_url":"https://api.github.com/users/jujing/events{/privacy}","received_events_url":"https://api.github.com/users/jujing/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/logcabin/logcabin/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-31T12:07:52Z","updated_at":"2015-09-02T00:36:48Z","closed_at":null,"body":"In /Server/StateMachine.cc, function StateMachine::shouldTakeSnapshot, line 599 (version: 1.1.0)\r\n    uint64_t curr = 0;\r\n    if (lastIncludedIndex > stats.last_snapshot_index())\r\n        curr = lastIncludedIndex - stats.last_snapshot_index();\r\n    uint64_t prev = curr - 1;\r\n\r\nSubtract operation overflows on operands \"curr\" and \"1UL\", whose values are unsigned constants, 0 and 1, respectively."},"comment":{"url":"https://api.github.com/repos/logcabin/logcabin/issues/comments/136902933","html_url":"https://github.com/logcabin/logcabin/issues/190#issuecomment-136902933","issue_url":"https://api.github.com/repos/logcabin/logcabin/issues/190","id":136902933,"user":{"login":"jujing","id":13994277,"avatar_url":"https://avatars.githubusercontent.com/u/13994277?v=3","gravatar_id":"","url":"https://api.github.com/users/jujing","html_url":"https://github.com/jujing","followers_url":"https://api.github.com/users/jujing/followers","following_url":"https://api.github.com/users/jujing/following{/other_user}","gists_url":"https://api.github.com/users/jujing/gists{/gist_id}","starred_url":"https://api.github.com/users/jujing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jujing/subscriptions","organizations_url":"https://api.github.com/users/jujing/orgs","repos_url":"https://api.github.com/users/jujing/repos","events_url":"https://api.github.com/users/jujing/events{/privacy}","received_events_url":"https://api.github.com/users/jujing/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T00:36:48Z","updated_at":"2015-09-02T00:36:48Z","body":"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. \r\nFor 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. "}}