-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
4.7.2, 4.7.3, 4.8.0
-
None
-
Discovered on Mac OS X 10.5 on a PowerPC.
corelib/tools/qelapsedtimer_mac.cpp, static qint64 absoluteToNSecs(qint64 cpuTime)
Integer overflow in line:
qint64 nsecs = cpuTime * info.numer / info.denom;
On PowerPC Macs, info.numer can be 1,000,000,000. Multiplying this by cpuTime can overflow the maximum value of qint64, leading to all sorts of wacky results. Suggested fix:
qint64 nsecs = cpuTime * ( (double)info.numer / (double)info.denom );
(As an aside, wherever absoluteToNSecs() or absoluteToMSecs() are called it is smashing an unsigned integer into a signed integer. But I haven't found that to be problematic.)
Worst case scenario: on a QThread that has a QTimer with a 5 second repeating timeout, this integer overflow may cause QTimerInfoList::timerWait to calculate a timeval that is too big for system ::select() to handle, which causes ::select to return EINVAL, which forces the event loop into a cpu-hogging cycle.