[Interest] QTimer::singleshot extending into global destruction phase
René J.V. Bertin
rjvbertin at gmail.com
Sun May 31 16:09:23 CEST 2020
Hi,
I have an application with a lengthy shutdown procedure that's been known to get stuck. So, I added
static bool coreShuttingDown = true;
QTimer::singleShot(60000, [&] {
if (coreShuttingDown) {
// when our time is up, raise the SIGHUP signal that causes us to exit "barely cleanly".
qCCritical(SHELL) << "We didn't shut down in under a minute; calling it quits";
std::raise(SIGHUP);
}
});
core->shutdown();
coreShuttingDown = false;
to the cleanup routine. I've assumed that this singleshot timer will be destroyed during the global destruction, and most of the time that does appear to be the case. Sometimes however this app gets stuck very late in the GD phase, apparently in a deadlock that doesn't contain any clue on what's causing it (a mutex destroyed before freeing it?).
I was going to add a lowlevel, SIGALARM based version of this protection; should I rather replace the QTimer::singleShot version or can I be certain that that cannot be the cause for the deadlock I'm seeing?
Thanks,
R.
More information about the Interest
mailing list