I think to trigger the issue, you need to arrive to the rounding error in 
delta, which happens if every cleanup task returned END_OF_TIME and we subtract 
now timestamp from it:
---
#include <iostream>
#include <limits>
#define MAX_VAL(x) (std::numeric_limits< x >::max())
static const time_t END_OF_TIME(MAX_VAL(time_t)-2);

int main() {
        time_t now = time(0);
        time_t diff = END_OF_TIME - now;
        std::cout << (diff) << "   " << long(diff) << std::endl;
}
---

$ ./a.out 
9223372035111660800   -174311500

I am not sure how to reproduce it reliably with the service itself,
maybe it is possible to provide a unit test with gtest/gmock or an
integration test.

Also it seems that it should be sufficient to define time_t DAY = 84600;
and use it in

                wait_for(g, std::min(delta, DAY), 1);

without other changes, as the variables are already time_t and the
invalid conversion happens inside this line.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2100887

Title:
  SRU: time_t overflow on certain architectures (100% CPU)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt-cacher-ng/+bug/2100887/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to