Hello,
We used POCO library in our project on Linux and found 3 issues which forced us to make changes in POCO sources. One of them is clearly a bug, and I want to start from it.
Let's look at Timer::start (Foundation/src/Timer.cpp):
nextInvocation += _startInterval*1000;
Then in Timer::run twice:
_nextInvocation += interval*1000;
Note that _startInterval and interval are declared as long, and 1000 is int.
What will happen on 32-bit OS when you want to wait for initial timer run or have interval between runs as quite a long time? Hours or days? When converted to microseconds, that interval will overflow long data type which is 4-byte on 32-bit OS. Let's check - 24 hours = 86,400 seconds = 86,400,000,000 microseconds (86 billion). 4-byte integer can hold only 2 billion (OK, 2,147,483,647).
As you see, it is quite easy to overflow long on 32-bit OS when using microseconds. However, fix is easy - when multiplying 2 numbers and none of them in 64-bit, just convert one of them to Int64. For example:
nextInvocation += Int64(_startInterval)*1000;
This will make compiler use Int64 when doing multiplication, and thus 64-bit integer math rather than 32-bit. We have applied and verified this fix with long initial and periodic intervals on 32-bit Linux and it worked fine.





