Skip to content

Commit

Permalink
fix #2109
Browse files Browse the repository at this point in the history
seems to be a race condition on qt6 (qt5 seems fine)
clear stack trace cookie leads to empty activeEnv in checkLine
(syntaxcheck)
  • Loading branch information
sunderme committed Feb 14, 2022
1 parent ae61879 commit db06d7d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/latexdocument.cpp
Expand Up @@ -2846,9 +2846,9 @@ bool LatexDocument::updateCompletionFiles(const bool forceUpdate, const bool for
parent->requestQNFAupdate();


if (!dontPatch && !newCmds.isEmpty()) {
patchLinesContaining(newCmds);
}
/*if (!dontPatch && !newCmds.isEmpty()) {
patchLinesContaining(newCmds); // deactivate as it seems to lead to a race conditions/crash (#2109)
}*/

if (delayUpdate)
return update;
Expand Down Expand Up @@ -3298,14 +3298,13 @@ void LatexDocument::reCheckSyntax(int lineStart, int lineNum)
if (lineStart == lineEnd) {
return;
}

// Delete the environment cookies for the specified lines to force their re-check
for (int i = lineStart; i < lineEnd; ++i) {
// We rely on the fact that QDocumentLine::removeCookie() holds a write lock of the corresponding
// line handle while removing the cookie. Lack of write locking causes crashes due to simultaneous
// access from the syntax checker thread.
line(i).removeCookie(QDocumentLine::STACK_ENVIRONMENT_COOKIE);
}
} //crash in qt6, looks like race coming from patchLines...

// Enqueue the first line for syntax checking. The remaining lines will be enqueued automatically
// through the checkNextLine signal because we deleted their STACK_ENVIRONMENT_COOKIE cookies.
Expand Down

0 comments on commit db06d7d

Please sign in to comment.