forked from qt-creator/qt-creator
ClangCodeModel: Catch exceptions in semantic highlighter
I've repeatedly encountered std::bad_alloc recently, and would like to get more info about where it is triggered. The crash comes from Qt, apparently after the original thread has alresdy finished, so the original location is not found in the stack trace. Change-Id: I7bbdcce6534ea0c846a69af33ad8634c3415572d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <cmath>
|
||||
#include <new>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
@@ -1349,8 +1350,13 @@ void ClangdClient::Private::handleSemanticTokens(TextDocument *doc,
|
||||
doc = QPointer(doc), rev = doc->document()->revision(),
|
||||
clangdVersion = q->versionNumber(),
|
||||
this] {
|
||||
return Utils::runAsync(doSemanticHighlighting, filePath, tokens, text, ast, doc, rev,
|
||||
clangdVersion, highlightingTimer);
|
||||
try {
|
||||
return Utils::runAsync(doSemanticHighlighting, filePath, tokens, text, ast, doc,
|
||||
rev, clangdVersion, highlightingTimer);
|
||||
} catch (const std::exception &e) {
|
||||
qWarning() << "caught" << e.what() << "in main highlighting thread";
|
||||
return QFuture<HighlightingResult>();
|
||||
}
|
||||
};
|
||||
|
||||
if (isTesting) {
|
||||
|
||||
Reference in New Issue
Block a user