Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
4.7.4
-
None
-
Mac OS X 10.5.8, PPC
Description
Hi,
I have a few Qt applications (e.g. Qt Designer) that, all of a sudden, begin to spam my syslog with zillions of "select: invalid argument" messages. These messages are generated faster than they are written to disk, and syslogd eats all the system memory for buffering, bringing the whole system to crawl.
The error message is generated in QEventDispatcherUNIXPrivate::doSelect():
// EINVAL... shouldn't happen, so let's complain to stderr // and hope someone sends us a bug report perror("select");
So here is the bug report...
The man page gives two reasons for EINVAL:
[EINVAL] The specified time limit is invalid. One of its com- ponents is negative or too large. [EINVAL] ndfs is greater than FD_SETSIZE and _DARWIN_UNLIM- ITED_SELECT is not defined.
Further investigation shows that:
- the messages begin after select() was called with a timeout value with tv_sec ~ 1.2e9
- Darwin select() implementation returns EINVAL if the tv_sec field is >= 1e8
The root cause seems to be located here (qelapsedtimer_mac.cpp):
static qint64 absoluteToNSecs(qint64 cpuTime) { if (info.denom == 0) mach_timebase_info(&info); qint64 nsecs = cpuTime * info.numer / info.denom; return nsecs; }
The problem here is that the multiplication can overflow.
The latest debugging session gave these values right before the first invalid argument message:
info.numer 1000000000 info.denom 18431648 cpu_time 5072980886283 nsecs 6850500447
This is called from
QEventDispatcherUNIX::processEvents() -> QTimerInfoList::timerWait() -> QTimerInfoList::updateCurrentTime() -> qt_gettime()
FWIW, the system in question is a G4 PowerBook with an uptime of 24 days.
The attached patch uses doubles to work around the overflow.
Attachments
For Gerrit Dashboard: QTBUG-24031 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
77122,1 | Cocoa: work around integer multiplication overflow in qt_gettime() | 4.8 | qt/qt | Status: ABANDONED | -1 | 0 |
77141,2 | Cocoa: fix integer multiplication overflow in qt_gettime() | stable | qt/qtbase | Status: ABANDONED | +2 | 0 |
98342,1 | Cocoa: fix integer multiplication overflow in qt_gettime() | 5.4 | qt/qtbase | Status: ABANDONED | -2 | 0 |
123020,3 | Cocoa: fix integer multiplication overflow in qt_gettime() | 5.5 | qt/qtbase | Status: MERGED | +2 | 0 |