Repository navigation
ci(linux): run the tests with AddressSanitizer and UBSan too - #12722
Merged
Merged
Conversation
|
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
This was referenced Nov 30, 2026
oc-tmueller
marked this pull request as ready for review
November 30, 2026 10:12
Add a second entry to the Linux job's matrix that builds the client's own code with ECM_ENABLE_SANITIZERS=address;undefined, with debug info, against the same Conan packages, and runs the whole test suite. Leak checking stays off for now, as the tests leak objects. The sanitizers write their reports to files, so that those of child processes such as test_helper aren't lost; a failed test run prints them and uploads them. The test step times out before the job does, so a hanging run still gets its logs. The QML format lint runs only in the plain build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
qApp is a static_cast of QCoreApplication::instance() to QGuiApplication or QApplication, depending on which of them is included. Theme's aboutVersions() and the Windows shutdown watcher used it in qobject_cast and invokeMethod, which also run in processes with just a QCoreApplication, such as the tests. That cast is undefined there, and UBSan reports it in every test that sets up logging. Use QCoreApplication::instance() instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
qGuiApp is a static_cast of QCoreApplication::instance() to QGuiApplication. isUsingDarkTheme(), buildAvatar() and the icon cache only used it to call the static styleHints() and palette(), but the cast is undefined in processes with just a QCoreApplication, e.g. the tests, which reach isUsingDarkTheme() through getCoreIcon(). UBSan reports it in ProtocolModelTest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A folder only gets its folder watcher once its virtual files plugin has started. wipeForRemoval() called disconnect() on it unconditionally, so removing a folder before then, e.g. when its account is deleted right after it was added, called a member function through a null pointer. UBSan reports it in FolderManTest. Check it, as the other uses do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oc-tmueller
force-pushed
the
ci/linux-asan
branch
from
November 30, 2026 10:16
4b8b7f8 to
b0eff13
Compare
erikjv
approved these changes
Nov 30, 2026
oc-tmueller
added a commit
that referenced
this pull request
Nov 30, 2026
Add a second entry to the Linux job's matrix that builds the client's own code with ECM_ENABLE_SANITIZERS=address;undefined, with debug info, against the same Conan packages, and runs the whole test suite. Leak checking stays off for now, as the tests leak objects. The sanitizers write their reports to files, which a failed run prints and uploads. Also don't static_cast a QCoreApplication to the GUI classes through qApp in Theme::aboutVersions() and the Windows shutdown watcher, which UBSan reports in every test on master. Backport of #12722 to 6, which differs from master: - theme.h includes <qquickwindow.h>, so qApp is a static_cast to QGuiApplication in every file that includes it. In logger.cpp, which every test reaches through Logger::setLogFile(), and in Theme::wizardHeaderTitleColor(), call the static applicationName() and palette() through their classes instead. - There's no src/resources/iconresources.cpp, src/resources/resources.cpp has no qGuiApp use, and Folder::wipeForRemoval() resets its QScopedPointer folder watcher, which is safe without one, so those parts of #12722 don't apply. (cherry picked from commit 91ca6f5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 30, 2026
oc-tmueller
added a commit
that referenced
this pull request
Nov 30, 2026
…12735) ci(linux): run the tests with AddressSanitizer and UBSan too (#12722) * ci(linux): run the tests with AddressSanitizer and UBSan too Add a second entry to the Linux job's matrix that builds the client's own code with ECM_ENABLE_SANITIZERS=address;undefined, with debug info, against the same Conan packages, and runs the whole test suite. Leak checking stays off for now, as the tests leak objects. The sanitizers write their reports to files, so that those of child processes such as test_helper aren't lost; a failed test run prints them and uploads them. The test step times out before the job does, so a hanging run still gets its logs. The QML format lint runs only in the plain build. * fix(libsync): don't static_cast a QCoreApplication to the GUI classes qApp is a static_cast of QCoreApplication::instance() to QGuiApplication or QApplication, depending on which of them is included. Theme's aboutVersions() and the Windows shutdown watcher used it in qobject_cast and invokeMethod, which also run in processes with just a QCoreApplication, such as the tests. That cast is undefined there, and UBSan reports it in every test that sets up logging. Use QCoreApplication::instance() instead. * fix(resources): call QGuiApplication's static members directly qGuiApp is a static_cast of QCoreApplication::instance() to QGuiApplication. isUsingDarkTheme(), buildAvatar() and the icon cache only used it to call the static styleHints() and palette(), but the cast is undefined in processes with just a QCoreApplication, e.g. the tests, which reach isUsingDarkTheme() through getCoreIcon(). UBSan reports it in ProtocolModelTest. * fix(gui): don't use the folder watcher of a folder that has none yet A folder only gets its folder watcher once its virtual files plugin has started. wipeForRemoval() called disconnect() on it unconditionally, so removing a folder before then, e.g. when its account is deleted right after it was added, called a member function through a null pointer. UBSan reports it in FolderManTest. Check it, as the other uses do. --------- (cherry picked from commit 91ca6f5) Co-authored-by: Thomas Müller <323649642+oc-tmueller@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
oc-tmueller
added a commit
that referenced
this pull request
Nov 30, 2026
) ci(linux): run the tests with AddressSanitizer and UBSan too (#12722) Add a second entry to the Linux job's matrix that builds the client's own code with ECM_ENABLE_SANITIZERS=address;undefined, with debug info, against the same Conan packages, and runs the whole test suite. Leak checking stays off for now, as the tests leak objects. The sanitizers write their reports to files, which a failed run prints and uploads. Also don't static_cast a QCoreApplication to the GUI classes through qApp in Theme::aboutVersions() and the Windows shutdown watcher, which UBSan reports in every test on master. Backport of #12722 to 6, which differs from master: - theme.h includes <qquickwindow.h>, so qApp is a static_cast to QGuiApplication in every file that includes it. In logger.cpp, which every test reaches through Logger::setLogFile(), and in Theme::wizardHeaderTitleColor(), call the static applicationName() and palette() through their classes instead. - There's no src/resources/iconresources.cpp, src/resources/resources.cpp has no qGuiApp use, and Folder::wipeForRemoval() resets its QScopedPointer folder watcher, which is safe without one, so those parts of #12722 don't apply. (cherry picked from commit 91ca6f5) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
Build and test linux-x86_64-asanas a second entry of the Linux job's matrix, and fixes what it found. The plain entry keeps its name,Build and test linux-x86_64.The job
ECM_ENABLE_SANITIZERS='address;undefined'and-O3 -g, against the same Conan archive from ghcr.io; the dependencies aren't instrumented and aren't rebuilt.ASAN_OPTIONS=detect_leaks=0:halt_on_error=1andUBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1. Leak checking is off for now: the tests leak objects (e.g.TestOAuth's accounts), which would need suppressions first.$RUNNER_TEMP/sanitizers, so those of child processes liketest_helperaren't lost; a failed run prints them in the log and uploads them asconan-build-linux-x86_64-asan-sanitizer-reports.vm.mmap_rnd_bits=28: gcc 13's ASan runtime is known to crash at start with the 32 bits of mmap randomization of newer kernels.Linux rather than macOS: locally on macOS, the ASan runtime crashes now and then in the forked child when
QProcessstartstest_helper, which fails tests that use the helper. The job adds a second Linux run of roughly 1.5 to 2 times the plain one's length; the plain build doesn't change.What it found
All UBSan, no ASan reports. Each test stopped at its first report, so the later ones only showed up once the earlier ones were fixed:
src/libsync/theme.cpp:170, 24 of 37 tests:qobject_cast<QGuiApplication *>(qApp). With<QGuiApplication>included,qAppisstatic_cast<QGuiApplication *>(QCoreApplication::instance()), a downcast to a type the object doesn't have in the GUI-less tests (QTEST_GUILESS_MAIN). Every test reaches it throughsetUpTests()→Logger::setLogFile()→Theme::aboutVersions(). Fixed byQCoreApplication::instance(), also for the same pattern inplatform_win.cpp(twice).src/resources/iconresources.cpp:45,ProtocolModelTest:qGuiApp->styleHints(), the same cast, only to call a static member. Fixed by callingQGuiApplication::styleHints()andQGuiApplication::palette()directly, iniconresources.cppandresources.cpp.src/gui/folder.cpp:770,FolderManTest:Folder::wipeForRemoval()calleddisconnect()on the folder watcher, which a folder only gets once its virtual files plugin has started: a call through a null pointer. Fixed by a check, as the other uses do. fix(gui): don't start the virtual files of a removed folder #12731 fixes the removal of such a folder more broadly and contains the same check, with the same wording.With these, the whole suite passes under ASan and UBSan. The remaining
qApp/qGuiAppuses insrc/libsync,src/resourcesandsrc/common, which are only correct because of what those files include, are #12730.Context: the use-after-free in #12716 was found with ASan and isn't visible in normal builds; once its
PropagatorTeardownTestis on master, this job catches a regression of it.🤖 Generated with Claude Code