From 85e14a0d72b3470748e3cbe8871e23a818820ee9 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 23 Feb 2018 14:24:21 +0100 Subject: Add rudimentary support for address sanitizer builds This change adds a new setup.py option called --sanitize-address which will build all executables and shared libraries with address sanitizer enabled. The builds will only succeed on Linux and macOS machines that have new enough gcc / clang versions, so it is a "use at your own risk" build configuration. This change was necessitated by the random crashes that are sometimes observed on the CI machines, and due to valgrind not working properly on new macOS versions, using AddressSanitizer is the next best thing. Note that when running tests with address sanitizer builds, you might need to export a LD_PRELOAD / DYLD_INSERT_LIBRARIES environment variable pointing to the address sanitizer runtime library path, which will be provided by the crashed application. Change-Id: I93014002e5c5e94bcc808ba2fb830d60724cfb69 Reviewed-by: Christian Tismer --- sources/pyside2/CMakeLists.txt | 16 ++++++++++++++++ sources/shiboken2/CMakeLists.txt | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'sources') diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt index 08ed52473..fac031fdb 100644 --- a/sources/pyside2/CMakeLists.txt +++ b/sources/pyside2/CMakeLists.txt @@ -398,6 +398,22 @@ else() message(STATUS "PySide will be generated using the protected hack!") endif() +# Build with Address sanitizer enabled if requested. This may break things, so use at your own risk. +if (SANITIZE_ADDRESS AND NOT MSVC) + # Currently this does not check that the clang / gcc version used supports Address sanitizer, + # so once again, use at your own risk. + add_compile_options("-fsanitize=address" "-g" "-fno-omit-frame-pointer") + # We need to add the sanitize address option to all linked executables / shared libraries + # so that proper sanitizer symbols are linked in. + # + # Note that when running tests, you may need to set an additional environment variable + # in set_tests_properties for shiboken2 / pyside tests, or exported in your shell. Address + # sanitizer will tell you what environment variable needs to be exported. For example: + # export DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/ + # ./XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_STANDARD_LIBRARIES} -fsanitize=address") +endif() + add_subdirectory(libpyside) find_package(Qt5Designer) if(Qt5UiTools_FOUND AND Qt5Designer_FOUND) diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt index 238ee2d34..c5cca506e 100644 --- a/sources/shiboken2/CMakeLists.txt +++ b/sources/shiboken2/CMakeLists.txt @@ -144,6 +144,22 @@ if(CMAKE_HOST_APPLE) endif() endif() +# Build with Address sanitizer enabled if requested. This may break things, so use at your own risk. +if (SANITIZE_ADDRESS AND NOT MSVC) + # Currently this does not check that the clang / gcc version used supports Address sanitizer, + # so once again, use at your own risk. + add_compile_options("-fsanitize=address" "-g" "-fno-omit-frame-pointer") + # We need to add the sanitize address option to all linked executables / shared libraries + # so that proper sanitizer symbols are linked in. + # + # Note that when running tests, you may need to set an additional environment variable + # in set_tests_properties for shiboken2 / pyside tests, or exported in your shell. Address + # sanitizer will tell you what environment variable needs to be exported. For example: + # export DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/ + # ./XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_STANDARD_LIBRARIES} -fsanitize=address") +endif() + add_subdirectory(ApiExtractor) set(generator_plugin_DIR ${LIB_INSTALL_DIR}/generatorrunner${generator_SUFFIX}) -- cgit v1.2.3 From 6c0a0d70305cd6e12260a352099e74d34f3c239e Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Tue, 27 Feb 2018 14:44:39 +0100 Subject: Fix QValidator fixup() behavior The return value from the fixup() method was ignored leaving an Intermediate or Invalid input intact. This was solved injecting code to the native wrapper for the fixup() method that allows to change its value. A test case is provided. Task-number: PYSIDE-106 Change-Id: I1d796955178dbdbcfff90adb6ede5c8b2dd1acc3 Reviewed-by: Friedemann Kleint Reviewed-by: Alexandru Croitor --- .../PySide2/QtGui/typesystem_gui_common.xml | 3 +++ sources/pyside2/PySide2/typesystem_templates.xml | 6 +++++ sources/pyside2/tests/QtWidgets/qvalidator_test.py | 27 ++++++++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-) (limited to 'sources') diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml index 55bc438be..2578a1aa9 100644 --- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml +++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml @@ -1713,6 +1713,9 @@ + + + diff --git a/sources/pyside2/PySide2/typesystem_templates.xml b/sources/pyside2/PySide2/typesystem_templates.xml index 7ac4ac158..e0b47b6e3 100644 --- a/sources/pyside2/PySide2/typesystem_templates.xml +++ b/sources/pyside2/PySide2/typesystem_templates.xml @@ -278,6 +278,12 @@ +