summaryrefslogtreecommitdiffstats
path: root/src/qdoc/qdoc/tests/validateqdocoutputfiles
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2024-06-06 14:24:23 +0200
committerPaul Wicking <paul.wicking@qt.io>2024-06-07 15:45:45 +0200
commit31835b4c9f31ffdf17202d1bf257d68f1adb0ce1 (patch)
tree811e062bab715de8802ead8bc2bd5ad1a583594a /src/qdoc/qdoc/tests/validateqdocoutputfiles
parent413ab356162340138a20de98bc60ad8e3f4250a8 (diff)
QDoc: Disable ASan sigaltstack in output testHEADdev
Due to ASan's use of sigaltstack, it can crash with deallocation errors if instrumenting binaries that also use sigaltstack (directly or transitively). As LLVM has its own sigaltstack, this has caused integration failures in COIN (see related Jira issues). This is a known issue, see e.g: https://github.com/google/sanitizers/issues/849 https://github.com/KDE/kdevelop/commit/e306f3e39aba37b606dadba195fa5b7b73816f8f Modify the test binary such that it sets or extends the `ASAN_OPTIONS` environment variable for QDoc's process environment, to avoid crash in ASan. Promote the existing QProcessEnvironment to a static that is shared between the `initTestCase` and `runQDocProcess` member functions, to avoid the cost of repeatedly creating the QPE object. Fixes: QTBUG-126116 Task-number: QTBUG-111580 Pick-to: 6.8 Change-Id: I25c7baed9ccec14aaad0c47512b58118a3a91d84 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/qdoc/tests/validateqdocoutputfiles')
-rw-r--r--src/qdoc/qdoc/tests/validateqdocoutputfiles/tst_validateqdocoutputfiles.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/qdoc/qdoc/tests/validateqdocoutputfiles/tst_validateqdocoutputfiles.cpp b/src/qdoc/qdoc/tests/validateqdocoutputfiles/tst_validateqdocoutputfiles.cpp
index bcabb4178..a3c08ad7b 100644
--- a/src/qdoc/qdoc/tests/validateqdocoutputfiles/tst_validateqdocoutputfiles.cpp
+++ b/src/qdoc/qdoc/tests/validateqdocoutputfiles/tst_validateqdocoutputfiles.cpp
@@ -26,21 +26,32 @@ private:
QScopedPointer<QTemporaryDir> m_outputDir{};
};
+static constexpr QLatin1StringView ASAN_OPTIONS_ENVVAR{"ASAN_OPTIONS"};
static inline bool regenerate{false};
//! Update `README.md` if you change the name of this environment variable!
static constexpr QLatin1StringView REGENERATE_ENVVAR{"QDOC_REGENERATE_TESTDATA"};
+static QProcessEnvironment s_environment {QProcessEnvironment::systemEnvironment()};
void tst_validateQdocOutputFiles::initTestCase()
{
- QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
- if (environment.contains(REGENERATE_ENVVAR)) {
+ if (s_environment.contains(REGENERATE_ENVVAR)) {
qInfo() << "Regenerating expected output for all tests.";
regenerate = true;
qInfo("Removing %s environment variable.", REGENERATE_ENVVAR.constData());
- environment.remove(REGENERATE_ENVVAR);
+ s_environment.remove(REGENERATE_ENVVAR);
}
+ // We must disable the use of sigaltstack for ASan to work properly with QDoc when
+ // linked against libclang, to avoid a crash in ASan. This is a known issue and workaround,
+ // see e.g. https://github.com/google/sanitizers/issues/849 and
+ // https://github.com/KDE/kdevelop/commit/e306f3e39aba37b606dadba195fa5b7b73816f8f.
+ // We do this for the process environment of the QDoc process only to avoid affecting
+ // other processes that might be started by the test runner in COIN.
+ const QString optionString = s_environment.contains(ASAN_OPTIONS_ENVVAR) ? ",use_sigaltstack=0" : "use_sigaltstack=0";
+ s_environment.insert(ASAN_OPTIONS_ENVVAR, s_environment.value(ASAN_OPTIONS_ENVVAR) + optionString);
+ qInfo() << "Disabling ASan's alternate signal stack by setting `ASAN_OPTIONS=use_sigaltstack=0`.";
+
// Build the path to the QDoc binary the same way moc tests do for moc.
const auto binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
const auto extension = QSysInfo::productType() == "windows" ? ".exe" : "";
@@ -70,8 +81,8 @@ void tst_validateQdocOutputFiles::init()
void tst_validateQdocOutputFiles::runQDocProcess(const QStringList &arguments)
{
QProcess qdocProcess;
+ qdocProcess.setProcessEnvironment(s_environment);
qdocProcess.setProgram(m_qdocBinary);
-
qdocProcess.setArguments(arguments);
auto failQDoc = [&](QProcess::ProcessError) {