Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite hang with CodeChecker on clang without analyser #2670

Open
whisperity opened this issue Apr 3, 2020 · 3 comments
Open

Infinite hang with CodeChecker on clang without analyser #2670

whisperity opened this issue Apr 3, 2020 · 3 comments
Labels
analyzer 📈 Related to the analyze commands (analysis driver) bug 🐛 usability 👍 Usability-related features

Comments

@whisperity
Copy link
Contributor

Describe the bug
If the clang binary used from PATH is built without Clang Static Analyzer, the fetching of checkers hangs infinitely.

CodeChecker version
Irrelevant, but exists with 6.11.

To Reproduce
Steps to reproduce the behaviour:

  1. Build LLVM/Clang without ClangSA: cmake ... -DCLANG_ENABLE_STATIC_ANALYZER=OFF
  2. Put the Build/bin into PATH
  3. Run something from CodeChecker that has to fetch checkers: checkers, analyze.
  4. Wait infinitely.
  5. See error

Expected behaviour
Fetch that there are no ClangSA checkers in the list, but do not hang.

Desktop (please complete the following information)

  • OS: Linux

Additional context
The issue is due to Clang dumping checker list by calling clang++ -cc1 -analyzer-checker-help. If there is a static analyzer, this dumps the checker list and early returns — but if there is no ClangSA built, the call is "equivalent" to calling clang++ -cc1 which will wait for preprocessed text on the standard input.

In case the standard input is not the tty stdin, but a file, e.g. calling: echo "" | clang -cc1 -analyzer-checker-help

  • when there is ClangSA built: same output as usual
  • when there is no ClangSA: output is an empty string, but the binary exits immediately and without side effects seemingly.

The issue might need to be fixed within Clang, in addition, because it is bad behaviour there that it starts waiting for stdin...

@whisperity whisperity added bug 🐛 analyzer 📈 Related to the analyze commands (analysis driver) usability 👍 Usability-related features labels Apr 3, 2020
@irishrover
Copy link
Contributor

It's called via subprocess.check_output, so timeout param can be used to fix the hang.

https://docs.python.org/3/library/subprocess.html#subprocess.check_output

@whisperity
Copy link
Contributor Author

Is timeout a good choice? The problem with timeouts is that we can never know what's sensible. If we set it to, let's say, 10 seconds, but the machine the tool is running on is so loaded (or has network-mounted storage?) that loading the checker list (for example if plugins are used) would take 15 seconds, it'll falsely say that there are no checkers.

@whisperity
Copy link
Contributor Author

Another interesting thing: I tried disabling clangsa by specifying --analyzers clang-tidy to the analyze command but it still tries to access the clang binary (for some resource dir printing stuff) and also tries getting the checkers, resulting in this hang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) bug 🐛 usability 👍 Usability-related features
Projects
None yet
Development

No branches or pull requests

2 participants