diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2017-11-23 13:42:28 +0100 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2017-11-23 18:13:52 +0000 |
commit | 46c27014d9b31cb24d463c689bb0a7958389dd1e (patch) | |
tree | 694a1d314a6727e28d3ddb143f37429599c563a3 /sources | |
parent | 2663162c9038a1151076b7efd3ae53e48e3818df (diff) |
Fix crashes on RHEL 6.6 CI machines due to a race condition in glib2
When Qt launches the QXcbEventReader thread, by default the created
thread dispatcher will call g_thread_init_glib to initialize the glib
thread. When libqgtk2 plugin is loaded, the plugin calls gtk_init
which also needs to initialize the glib thread library.
This can cause a race condition where the xcb thread might not finish
initializing all of the glib thread library, but the main thread
believes that initializing is done, and thus ends up dereferencing
null pointers.
Specifically when the glib function g_slice_alloc is called in the main
thread, which calls allocator_categorize, the glib initialization flag
'sys_page_size' is checked. This flag can already be set by the call
to g_slice_init_nomessage in the xcb thread, but magazine_mutex might not
yet be allocated (in g_slice_thread_init_nomessage), and the main
thread ends up dereferencing a null pointer mutex.
Relevant code can be found at
https://sourcecodebrowser.com/glib2.0/2.27.4/gslice_8c_source.html
The workaround is to set the QT_NO_GLIB environment variable
to 1 when running the tests, so that a regular
QEventDispatcherUNIX is used. Thus only the gtk plugin will call the
glib initialization function, eliminating the race condition.
Note that the issue probably happens only for glib versions < 2.32.
The g_thread_init function is deprecated since 2.32, and glib thread
initialization is done at the start of the program, as referenced at
https://developer.gnome.org/glib/2.32/glib-Deprecated-Thread-APIs.html#g-thread-init
Task-number: QTBUG-64716
Change-Id: Ibcccf8f6e0a3299e61dd320eb6d08e29658298e2
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside2/tests/CMakeLists.txt | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sources/pyside2/tests/CMakeLists.txt b/sources/pyside2/tests/CMakeLists.txt index 0bcbd640c..3440c1591 100644 --- a/sources/pyside2/tests/CMakeLists.txt +++ b/sources/pyside2/tests/CMakeLists.txt @@ -40,10 +40,12 @@ else() endif() set(TEST_CMD ${XVFB_EXEC} ${SHIBOKEN_PYTHON_INTERPRETER} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") add_test(${TEST_NAME} ${TEST_CMD}) + # QT_NO_GLIB=1 is required to avoid crashes on CI RHEL 6.6 machines. + # See QTBUG-64716 for details. set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT ${CTEST_TESTING_TIMEOUT} WILL_FAIL ${EXPECT_TO_FAIL} - ENVIRONMENT "PYTHONPATH=${TEST_PYTHONPATH};${LIBRARY_PATH_VAR}=${TEST_LIBRARY_PATH};PYSIDE_DISABLE_INTERNAL_QT_CONF=1") + ENVIRONMENT "PYTHONPATH=${TEST_PYTHONPATH};${LIBRARY_PATH_VAR}=${TEST_LIBRARY_PATH};PYSIDE_DISABLE_INTERNAL_QT_CONF=1;QT_NO_GLIB=1") endmacro() add_subdirectory(pysidetest) |