Go to file
Tor Arne Vestbø 46667d604f Fix crash when re-creating QThreadData after initially destroying it
We destroy the thread data for the main thread when the QCoreApplication
is destructed, and then delete the pthread key for the thread data in
the global static destructor function 'destroy_current_thread_data_key'.

The user may have its own Q_DESTRUCTOR_FUNCTION though, which may or may
not run after we've destroyed the key. If it runs after we've destroyed
the key, we'll end up trying to re-create the tread-data, as expected,
but set_thread_data() will fail to persist it, as pthread_setspecific
is called with an invalid key. The result is an infinite recursion:

...
6  in QThreadData::current () at qthread_unix.cpp:216
7  in QObject::QObject (this=0x48e1b30, dd=@0x48e1b40, parent=0x0) at qobject.cpp:703
8  in QThread::QThread (this=0x48e1b30, dd=@0x48e1b40, parent=0x0) at qthread.cpp:396
9  in QAdoptedThread::QAdoptedThread (this=0x48e1b30, data=0x48e1af0) at qthread.cpp:120
10 in QAdoptedThread::QAdoptedThread (this=0x48e1b30, data=0x48e1af0) at qthread.cpp:130
11 in QThreadData::current () at qthread_unix.cpp:219
12 in QObject::QObject (this=0x48e1a20, dd=@0x48e1a30, parent=0x0) at qobject.cpp:703
...

To solve this, we reset current_thread_data_once when destroying the key,
so that subsequent calls to pthread_once to potentially create the key
will call create_current_thread_data_key once more. This means we'll leak
the key for this particular use-case, since we don't end up calling
pthread_key_delete a second time, but this leak is small and happens
typically only for a short duration during application shutdown.

Change-Id: I580484a3239849e891172e24e7f77b75afd2c51b
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-06-14 10:07:14 +02:00
bin don't touch deprecated headers unless they actually change 2013-06-12 13:03:06 +02:00
config.tests Add xcb-xkb to 3rd party libs 2013-05-07 22:43:14 +02:00
dist Revert QDateTime serialisation to pre-Qt 5 behaviour. 2013-05-08 10:00:29 +02:00
doc Update Urls to CMake docs. 2013-05-20 12:06:48 +02:00
examples docs: DirView example uses QFileSystemModel not QDirModel 2013-05-31 17:46:08 +02:00
lib
mkspecs Merge "Merge remote-tracking branch 'origin/release' into stable" into refs/staging/stable 2013-06-10 19:54:53 +02:00
qmake Xcode: Don't set TARGET_BUILD_DIR; that's handled by a copy phase 2013-06-11 16:35:53 +02:00
src Fix crash when re-creating QThreadData after initially destroying it 2013-06-14 10:07:14 +02:00
tests QDockWidget: Keep position when undocking. 2013-06-12 12:42:51 +02:00
tools Only process vcproj files if we do a -fully-process 2013-06-03 17:59:53 +02:00
util Don't show a separate inspector for child windows. 2013-04-23 07:45:22 +02:00
.gitattributes Update the git-archive export options 2012-09-07 15:39:31 +02:00
.gitignore Long live QLockFile 2013-03-05 06:26:33 +01:00
.qmake.conf require modules to define their version 2013-03-06 18:01:13 +01:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
configure don't make qconfig.h read-only 2013-06-12 13:02:55 +02:00
configure.bat get rid of syncqt wrapper scripts 2013-05-13 21:54:48 +02:00
header.BSD Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.FDL Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.LGPL Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.LGPL-ONLY Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
INSTALL INSTALL: Fix URL of Installing Qt documentation 2013-04-11 16:09:07 +02:00
LGPL_EXCEPTION.txt Change copyrights from Nokia to Digia 2012-09-22 19:20:11 +02:00
LICENSE.FDL
LICENSE.GPL
LICENSE.LGPL Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
LICENSE.PREVIEW.COMMERCIAL Update LICENSE.PREVIEW.COMMERCIAL license 2013-06-03 20:04:26 +02:00
qtbase.pro always create qt_tool_syncqt.pri when shadow-building 2013-05-15 05:06:15 +02:00
sync.profile let configure create the forwarding qconfig.h again 2013-06-03 17:59:31 +02:00