This is an archive of the discontinued LLVM Phabricator instance.

[clangd] abort if shutdown takes more than a minute.
ClosedPublic

Authored by sammccall on Oct 23 2019, 2:11 AM.

Details

Summary

A certain class of bug (e.g. infloop on an AST worker thread) currently means
clangd never terminates, even if the editor shuts down the protocol and closes
our stdin, and the main thread recognizes that.

Instead, let's wait 60 seconds for threads to finish cleanly, and then crash
if they haven't.

(Obviously, we should still fix these bugs).

Diff Detail

Event Timeline

sammccall created this revision.Oct 23 2019, 2:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 23 2019, 2:11 AM

Not sure 60 is enough, e.g. building a preamble can often take more than a minute and the users will see clangd crashing for (seemingly) no reason on shutdown.
In the long run, we should probably attempt to cancel long-running operations within a much shorter timeframe and a timeout of a minute would make more sense, though.

clang-tools-extra/clangd/tool/ClangdMain.cpp
689

Did you mean 60 seconds?

Build result: fail - 59551 tests passed, 1 failed and 805 were skipped.

failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

sammccall updated this revision to Diff 226135.Oct 23 2019, 7:07 AM

change timeout to 5 min

Build result: fail - 59568 tests passed, 1 failed and 805 were skipped.

failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

Adding myself to the reviewers since I've already looked at it. Unless anyone objects.

clang-tools-extra/clangd/ClangdLSPServer.h
219

Maybe call Server.reset() in destructor?
This ensures ClangdServer is terminated first even if the members are re-ordered later

kadircet accepted this revision.Oct 23 2019, 8:39 AM

Sorry I somehow missed the fact that I was a reviewer :D

LGTM

clang-tools-extra/clangd/ClangdLSPServer.h
219

+1

This revision is now accepted and ready to land.Oct 23 2019, 8:39 AM
sammccall marked 3 inline comments as done.Oct 23 2019, 8:52 AM
This revision was automatically updated to reflect the committed changes.