[Interest] can the QRegExpEngine cache acces objects belonging to an unloaded library during global destruction?

René J. V. Bertin rjvbertin at gmail.com
Mon Jan 29 21:53:21 CET 2018


Thiago Macieira wrote:

> The plugins aren't unloaded when you call unload(), but they are unloaded when
> the application exits. There's no way to avoid that.

I guess not, no, though I'm not sure if Qt has do do the unloading and releasing 
itself (as opposed to just telling the plugins to prepare for being unloaded). I 
don't think there are still OSes out there that will leave dangling plugins in 
memory after unloading the app that loaded them.

What's the difference between unload() and release(), btw?

> Your crash happens after the QLibrary private global static has finished
> running.

Which appears to be beyond my control. Or should I say, the only control I have 
over that is a brute-force means to keep that QLibrary private global static 
alive a bit longer (and as luck has it, until after the QRegExpEngine cache has 
been destroyed)?

Apparently I'm not the first to run into this problem. Assuming that the 
QRegExpEngine cache is indeed an important optimisation, wouldn't it be possible 
to empty it much earlier during the global destruction phase, and lock it? That 
way at least there is no more risk that the order changes again and my 
workaround no longer works.

Rewriting the QRegExpEngine cache implementation so it can connect to 
QCoreApplication::aboutToQuit and drain+lock itself shouldn't be very hard and 
should be completely invisible from the outside, no?

R.




More information about the Interest mailing list