From 4bb9dc1c712bca8a441f83bb74773e3d60b84c32 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 23:17:18 +0100 Subject: [PATCH 01/11] python: use `PY_VERSION_HEX` for version comparisons --- smtk/common/PythonInterpreter.cxx | 6 +++--- smtk/common/pybind11/PybindUUIDTypeCaster.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/smtk/common/PythonInterpreter.cxx b/smtk/common/PythonInterpreter.cxx index 2ad95d934a..3e51d92c20 100644 --- a/smtk/common/PythonInterpreter.cxx +++ b/smtk/common/PythonInterpreter.cxx @@ -105,7 +105,7 @@ void PythonInterpreter::initialize() // Locate the directory containing the python library in use, and set // PYTHONHOME to this path. static std::string pythonLibraryLocation = Paths::pathToLibraryContainingFunction(Py_Initialize); -#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3) || PY_MAJOR_VERSION > 3 +#if PY_VERSION_HEX >= 0x03030000 // Python 3.3 switched to wchar_t. static std::vector loc; loc.resize(pythonLibraryLocation.size() + 1); @@ -378,14 +378,14 @@ bool PythonInterpreter::loadPythonSourceFile( testCmd << "loaded = True\n" << "try:\n" -#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 5 +#if PY_VERSION_HEX >= 0x03050000 << " import sys, types, importlib.machinery\n" << " loader = importlib.machinery.SourceFileLoader('" << moduleName << "', '" << fileName << "')\n" << " mod = types.ModuleType(loader.name)\n" << " loader.exec_module(mod)\n" << " sys.modules['" << moduleName << "'] = mod\n" -#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3 && PY_MINOR_VERSION <= 4 +#elif PY_VERSION_HEX >= 0x03000000 << " from importlib.machinery import SourceFileLoader\n" << " tmp = SourceFileLoader('" << moduleName << "', '" << fileName << "').load_module()\n" diff --git a/smtk/common/pybind11/PybindUUIDTypeCaster.h b/smtk/common/pybind11/PybindUUIDTypeCaster.h index 64b9c897f6..da06a8d80a 100644 --- a/smtk/common/pybind11/PybindUUIDTypeCaster.h +++ b/smtk/common/pybind11/PybindUUIDTypeCaster.h @@ -41,7 +41,7 @@ public: throw reference_cast_error(); } -#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3) || PY_MAJOR_VERSION > 3 +#if PY_VERSION_HEX >= 0x03030000 char* ustr = uuidBytes ? PyBytes_AS_STRING(uuidBytes) : nullptr; #else char* ustr = uuidBytes ? PyString_AsString(uuidBytes) : nullptr; -- GitLab From 852fa26f179dd564905a12f677a58c156b512877 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 23:18:07 +0100 Subject: [PATCH 02/11] PythonInterpreter: remove Python2 support --- smtk/common/PythonInterpreter.cxx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/smtk/common/PythonInterpreter.cxx b/smtk/common/PythonInterpreter.cxx index 3e51d92c20..4a5187e11d 100644 --- a/smtk/common/PythonInterpreter.cxx +++ b/smtk/common/PythonInterpreter.cxx @@ -105,15 +105,11 @@ void PythonInterpreter::initialize() // Locate the directory containing the python library in use, and set // PYTHONHOME to this path. static std::string pythonLibraryLocation = Paths::pathToLibraryContainingFunction(Py_Initialize); -#if PY_VERSION_HEX >= 0x03030000 // Python 3.3 switched to wchar_t. static std::vector loc; loc.resize(pythonLibraryLocation.size() + 1); mbstowcs(loc.data(), pythonLibraryLocation.c_str(), static_cast(loc.size())); Py_SetProgramName(loc.data()); -#else - Py_SetProgramName(const_cast(pythonLibraryLocation.c_str())); -#endif // Initialize the embedded interpreter. Py_NoSiteFlag = 1; @@ -385,13 +381,10 @@ bool PythonInterpreter::loadPythonSourceFile( << " mod = types.ModuleType(loader.name)\n" << " loader.exec_module(mod)\n" << " sys.modules['" << moduleName << "'] = mod\n" -#elif PY_VERSION_HEX >= 0x03000000 +#else << " from importlib.machinery import SourceFileLoader\n" << " tmp = SourceFileLoader('" << moduleName << "', '" << fileName << "').load_module()\n" -#else /* PY_MAJOR_VERSION == 2 */ - << " import imp\n" - << " tmp = imp.load_source('" << moduleName << "', '" << fileName << "')\n" #endif << "except Exception as e:\n" << " print(e)\n" -- GitLab From bacffe252ae9ce70690196c6cdb8b581ccb9e989 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 23:18:28 +0100 Subject: [PATCH 03/11] PybindUUIDTypeCaster: remove Python 3.2 and older support --- smtk/common/pybind11/PybindUUIDTypeCaster.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/smtk/common/pybind11/PybindUUIDTypeCaster.h b/smtk/common/pybind11/PybindUUIDTypeCaster.h index da06a8d80a..21a94cebc8 100644 --- a/smtk/common/pybind11/PybindUUIDTypeCaster.h +++ b/smtk/common/pybind11/PybindUUIDTypeCaster.h @@ -41,11 +41,7 @@ public: throw reference_cast_error(); } -#if PY_VERSION_HEX >= 0x03030000 char* ustr = uuidBytes ? PyBytes_AS_STRING(uuidBytes) : nullptr; -#else - char* ustr = uuidBytes ? PyString_AsString(uuidBytes) : nullptr; -#endif if (ustr) { for (int i = 0; i < 16; ++i) -- GitLab From 40b55e381df908f0dd7d563597ecd256ed389f0a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 23:18:51 +0100 Subject: [PATCH 04/11] PythonInterpreter: remove Python 3.4 and older support --- smtk/common/PythonInterpreter.cxx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/smtk/common/PythonInterpreter.cxx b/smtk/common/PythonInterpreter.cxx index 4a5187e11d..a590ed5058 100644 --- a/smtk/common/PythonInterpreter.cxx +++ b/smtk/common/PythonInterpreter.cxx @@ -105,7 +105,6 @@ void PythonInterpreter::initialize() // Locate the directory containing the python library in use, and set // PYTHONHOME to this path. static std::string pythonLibraryLocation = Paths::pathToLibraryContainingFunction(Py_Initialize); - // Python 3.3 switched to wchar_t. static std::vector loc; loc.resize(pythonLibraryLocation.size() + 1); mbstowcs(loc.data(), pythonLibraryLocation.c_str(), static_cast(loc.size())); @@ -374,18 +373,12 @@ bool PythonInterpreter::loadPythonSourceFile( testCmd << "loaded = True\n" << "try:\n" -#if PY_VERSION_HEX >= 0x03050000 << " import sys, types, importlib.machinery\n" << " loader = importlib.machinery.SourceFileLoader('" << moduleName << "', '" << fileName << "')\n" << " mod = types.ModuleType(loader.name)\n" << " loader.exec_module(mod)\n" << " sys.modules['" << moduleName << "'] = mod\n" -#else - << " from importlib.machinery import SourceFileLoader\n" - << " tmp = SourceFileLoader('" << moduleName << "', '" << fileName - << "').load_module()\n" -#endif << "except Exception as e:\n" << " print(e)\n" << " loaded = False"; -- GitLab From b4720c74d8955224fe5cfd2db71dbba184196cc2 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 23:29:39 +0100 Subject: [PATCH 05/11] PythonInterpreter: use `PyConfig` initialization Supported since Python 3.8. --- smtk/common/PythonInterpreter.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/smtk/common/PythonInterpreter.cxx b/smtk/common/PythonInterpreter.cxx index a590ed5058..6b058566b8 100644 --- a/smtk/common/PythonInterpreter.cxx +++ b/smtk/common/PythonInterpreter.cxx @@ -105,14 +105,28 @@ void PythonInterpreter::initialize() // Locate the directory containing the python library in use, and set // PYTHONHOME to this path. static std::string pythonLibraryLocation = Paths::pathToLibraryContainingFunction(Py_Initialize); + size_t needed = mbstowcs(nullptr, pythonLibraryLocation.c_str(), 0); + +#if PY_VERSION_HEX >= 0x03080000 + PyConfig config; + PyConfig_InitPythonConfig(&config); + wchar_t* wcs_pn = (wchar_t*)PyMem_RawMalloc(sizeof(wchar_t) * (needed + 1)); + mbstowcs(wcs_pn, pythonLibraryLocation.c_str(), needed + 1); + config.program_name = wcs_pn; + config.site_import = 0; + + pybind11::initialize_interpreter(&config); + PyConfig_Clear(&config); +#else static std::vector loc; - loc.resize(pythonLibraryLocation.size() + 1); + loc.resize(needed + 1); mbstowcs(loc.data(), pythonLibraryLocation.c_str(), static_cast(loc.size())); Py_SetProgramName(loc.data()); // Initialize the embedded interpreter. Py_NoSiteFlag = 1; pybind11::initialize_interpreter(); +#endif // Locate the directory containing the library that describes this // class. -- GitLab From 5abcff25b39c260e8e8085b511ad22a2a1fcdfd1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 01:26:49 +0100 Subject: [PATCH 06/11] gitlab-ci: rename macOS builder tags to mention architecture --- .gitlab-ci.yml | 4 ++-- .gitlab/os-macos.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b160d9ef5..bbc5cedd72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -208,7 +208,7 @@ macos-x86_64:build: - .macos_x86_64 - .cmake_build_macos - .cmake_build_artifacts - - .macos_builder_tags + - .macos_x86_64_builder_tags - .run_automatically macos-x86_64:test: @@ -216,7 +216,7 @@ macos-x86_64:test: - .macos_x86_64 - .cmake_test_macos - .cmake_test_artifacts - - .macos_builder_tags + - .macos_x86_64_builder_tags - .run_dependent needs: - macos-x86_64:build diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml index fb7968f459..df7aef75e7 100644 --- a/.gitlab/os-macos.yml +++ b/.gitlab/os-macos.yml @@ -41,7 +41,7 @@ ## Tags -.macos_builder_tags: +.macos_x86_64_builder_tags: tags: - cmb - macos-x86_64 -- GitLab From 615472e2206018b752db17bb93b03530d45f6b66 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 01:27:03 +0100 Subject: [PATCH 07/11] gitlab-ci: update to Xcode 16.1 --- .gitlab/os-macos.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml index df7aef75e7..f49c4c2c6b 100644 --- a/.gitlab/os-macos.yml +++ b/.gitlab/os-macos.yml @@ -8,7 +8,7 @@ GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmb-ci-ext/$CI_CONCURRENT_ID" # TODO: Factor this out so that each job selects the Xcode version to # use so that different versions can be tested in a single pipeline. - DEVELOPER_DIR: "/Applications/Xcode-14.2.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode-16.1.app/Contents/Developer" # Avoid conflicting with other projects running on the same machine. SCCACHE_SERVER_PORT: 4228 @@ -46,7 +46,7 @@ - cmb - macos-x86_64 - shell - - xcode-14.2 + - xcode-16.1 - nonconcurrent .macos_arm64_builder_tags: @@ -54,7 +54,7 @@ - cmb - macos-arm64 - shell - - xcode-14.2 + - xcode-16.1 - nonconcurrent ## macOS-specific scripts -- GitLab From d2a4095e1da45b73dfe4c906fab2f3594a1b5609 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 01:32:55 +0100 Subject: [PATCH 08/11] gitlab-ci: update superbuild bundles to the latest This gets Xcode 16.1-compiled bundles and synchronizes all configurations on the same commit. --- .gitlab/ci/download_superbuild.cmake | 14 +++++++------- .gitlab/os-linux.yml | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitlab/ci/download_superbuild.cmake b/.gitlab/ci/download_superbuild.cmake index 743465dfa4..ee5e245c2b 100644 --- a/.gitlab/ci/download_superbuild.cmake +++ b/.gitlab/ci/download_superbuild.cmake @@ -8,16 +8,16 @@ cmake_minimum_required(VERSION 3.12) set(data_host "https://data.kitware.com") # Determine the tarball to download. ci-smtk-ci-developer-{date}-{git-sha}.tar.gz -# 20241101 - Update to use ParaView 5.13.1 and to fix Python Artifacts +# 20250105 - Update to use Xcode 16.1 if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "vs2022") - set(file_id "18XQy5PT34mDndeb_4KxiWB1Vfpa74w0F") - set(file_hash "76141151c2d9faa7df1321b24afc7b572212ee639ffb5564ccfadc99577c280427f7444c2ca998f06c0d131f0e1272aa061f7ee2bb5923f91cde18e94792020b") + set(file_id "1fv29BZW5MedtbwV_-XuvGFNYHNFLdVxm") + set(file_hash "7d0919c3217e143c4be6f4e7c4e47e5b9831858efc0a406f7531d09d091243fb5be44bc7ed7e26a4c61d81a5e57f38a453c253dcc8037d3ffe0fb7c9b09ba77f") elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "macos_x86_64") - set(file_id "1T3IdfGuYvRcrH3mK1c7fzIJbsc_u7Wp7") - set(file_hash "c9c0b1c65ec8c83620181f5a5ba54e6ed6e2d76a8ea08b800ee69c39033d4a36ca312b691eaaf86c20f3713d2a250451c231e7f6820d20bcea5d8d74235f02fc") + set(file_id "1q_yl0ZXBzXZu27CqH0RJIggUO0dcdzxz") + set(file_hash "a8cd9a32216b5c1153b1a37ff672941302004a64e066192288727c4b6be5c2fd6c57a818b9254c0d7aed5e8ed26bdd357d54224ce503468ed34b8352315f6138") elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "macos_arm64") - set(file_id "1L9yqQMJDw_peBTDcI6AbX4s8iLiQ8XWY") - set(file_hash "a87b1f079b8a4191d81a9b0726342714dd8ea8a60f2bc8fe9c6081fa30e2a9afaf70d3b6b821948033e01dceb7aca927b4635a69afee92f245e1f18a41c558e2") + set(file_id "1BluXPsmfRNqAqSpYahyvC6iWAVlJ0vzy") + set(file_hash "8e8a2f8492cc383658028184a25cd555f85697e2a0075c0792321de7980eda58e7b60c0ef5be743f253d44f5abaebf89852a606a90078214bb9eed885428ce73") else () message(FATAL_ERROR "Unknown build to use for the superbuild") diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index bd1c788902..2a163dc9bd 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -6,8 +6,8 @@ ### Fedora .fedora33: - # Update to use ParaView 5.13.1 and to fix Python Artifacts - image: "kitware/cmb:ci-smtk-fedora33-20241101" + # Xcode 16.1 update; synchronize with other platforms + image: "kitware/cmb:ci-smtk-fedora33-20250105" variables: GIT_SUBMODULE_STRATEGY: recursive @@ -67,14 +67,14 @@ .fedora33_vtk_python3: extends: .fedora33 - image: "kitware/cmb:ci-smtk-fedora33-vtk-20240724" + image: "kitware/cmb:ci-smtk-fedora33-vtk-20250105" variables: CMAKE_CONFIGURATION: fedora33_vtk_python3 .fedora33_paraview: extends: .fedora33 - image: "kitware/cmb:ci-smtk-fedora33-paraview-20241101" + image: "kitware/cmb:ci-smtk-fedora33-paraview-20250105" variables: CMAKE_CONFIGURATION: fedora33_paraview -- GitLab From ff27698c0ce1ba705a5978803f08e5c9ea871cfb Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Jan 2025 23:30:34 +0100 Subject: [PATCH 09/11] ci: disable broken contract testing --- .gitlab/ci/configure_fedora33_paraview.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/configure_fedora33_paraview.cmake b/.gitlab/ci/configure_fedora33_paraview.cmake index a09043cadf..1f88dbd07d 100644 --- a/.gitlab/ci/configure_fedora33_paraview.cmake +++ b/.gitlab/ci/configure_fedora33_paraview.cmake @@ -3,9 +3,11 @@ set(SMTK_PLUGIN_CONTRACT_FILE_URLS "https://gitlab.kitware.com/cmb/plugins/opencascade-session/-/raw/master/cmake/opencascade-smtk-contract.cmake" "https://gitlab.kitware.com/cmb/plugins/adh-extensions/-/raw/master/CMake/adh-extensions.cmake" "https://gitlab.kitware.com/cmb/plugins/rgg-session/-/raw/master/CMake/rgg-session.cmake" - "https://gitlab.kitware.com/cmb/plugins/truchas-extensions/-/raw/master/CMake/truchas-extensions.cmake" + # https://gitlab.kitware.com/cmb/smtk/-/issues/543 + # "https://gitlab.kitware.com/cmb/plugins/truchas-extensions/-/raw/master/CMake/truchas-extensions.cmake" "https://gitlab.kitware.com/cmb/cmb/-/raw/master/cmake/cmb.cmake" - "https://gitlab.kitware.com/cmb/plugins/ace3p-extensions/-/raw/master/CMake/ace3p-extensions.cmake" + # https://gitlab.kitware.com/cmb/smtk/-/issues/543 + # "https://gitlab.kitware.com/cmb/plugins/ace3p-extensions/-/raw/master/CMake/ace3p-extensions.cmake" "https://gitlab.kitware.com/cmb/plugins/xmsmeshoperation/-/raw/master/CMake/xms-mesh-operation.cmake" "https://gitlab.kitware.com/cmb/plugins/cmb-2d/-/raw/master/cmake/cmb-2d.cmake" CACHE STRING "") -- GitLab From daadc03b1285d125028589a1c54ae0122c7920c1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 7 Jan 2025 19:37:11 +0100 Subject: [PATCH 10/11] qtReferenceItem: ignore destruction events UBSan detects an invalid vtable pointer in `m_p->m_popup`'s inner pointer. Investigations uncovered that this happens during destruction of `QDialog`. Since the filter doesn't care about the events that observe this state, just avoid doing work during this delicate time. --- smtk/extension/qt/qtReferenceItem.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/smtk/extension/qt/qtReferenceItem.cxx b/smtk/extension/qt/qtReferenceItem.cxx index c069901d5e..086a06c8a7 100644 --- a/smtk/extension/qt/qtReferenceItem.cxx +++ b/smtk/extension/qt/qtReferenceItem.cxx @@ -758,6 +758,15 @@ void qtReferenceItem::updateSynopsisLabels() const bool qtReferenceItem::eventFilter(QObject* src, QEvent* event) { + // Filter events up front. UBSan is noticing that, during destruction of the widget tree, + // `m_popup` is transmogrified from a `QDialog` into a `QWidget` (this is called from the + // `QWidget` destructor). Do nothing for certain events to avoid looking at `m_popup` during + // this state. + if (event->type() == QEvent::ChildRemoved || event->type() == QEvent::Destroy) + { + return false; + } + // We serve as an event filter on 2 widgets: // 1. the inherited frame holding the item (m_widget), // which we monitor for the enter/exit events that enable hovering -- GitLab From ee82e87e59b92d1ab3ce13411ebba6883a7703fb Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 7 Jan 2025 19:38:44 +0100 Subject: [PATCH 11/11] ci: exclude `TestMutexedOperation` for segfaulting The backtrace is from HDF5 during program shutdown. It seems like it ends up being ordered after `malloc` has been destructed. Just ignore it and file an issue for now. --- .gitlab/ci/ctest_exclusions.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake index 1e99b2e5f6..e17fa8bfbe 100644 --- a/.gitlab/ci/ctest_exclusions.cmake +++ b/.gitlab/ci/ctest_exclusions.cmake @@ -18,6 +18,10 @@ if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "fedora") "^RenderMesh$" # QTest::qWaitForWindowActive fails on CI machines but works locally "^UnitTestDoubleClickButton$" + # Segfault; global dtor order where `H5P_close` tries to allocate memory after `malloc` + # machinery has been torn down + # https://gitlab.kitware.com/cmb/smtk/-/issues/544 + "^TestMutexedOperation$" ) endif () -- GitLab