clang-tidy crash with "LLVM ERROR: Cannot chdir into <sourcefile>"
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Trying to follow the instructions [here](https://blog.bkryza.com/posts/compile-commands-json-gallery/#xcode), the error message says cannot chdir into a __file__(!?)
```
%/opt/homebrew/Cellar/llvm/21.1.3/bin/clang-tidy -p ../build/xcode/ $PWD/src/maxmubu.c
Error while processing /Users/schwarz/src/mubu-git/maxmubu/src/maxmubu.c.
LLVM ERROR: Cannot chdir into "/Users/schwarz/src/mubu-git/maxmubu/src/imubudatagui.c"!
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/homebrew/Cellar/llvm/21.1.3/bin/clang-tidy -p /Users/schwarz/src/mubu-git/build/xcode /Users/schwarz/src/mubu-git/maxmubu/src/maxmubu.c
#0 0x0000000116cb36dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/homebrew/Cellar/llvm/21.1.3/lib/libLLVM.dylib+0x3dff6dc)
#1 0x0000000116cb3f20 SignalHandler(int, __siginfo*, void*) (/opt/homebrew/Cellar/llvm/21.1.3/lib/libLLVM.dylib+0x3dfff20)
#2 0x0000000190f516a4 (/usr/lib/system/libsystem_platform.dylib+0x1804ad6a4)
#3 0x0000000190f1788c (/usr/lib/system/libsystem_pthread.dylib+0x18047388c)
#4 0x0000000190e20a3c (/usr/lib/system/libsystem_c.dylib+0x18037ca3c)
#5 0x0000000112f31d48 write_retry(int, char const*, unsigned long) (/opt/homebrew/Cellar/llvm/21.1.3/lib/libLLVM.dylib+0x7dd48)
#6 0x00000001078375e8 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/opt/homebrew/Cellar/llvm/21.1.3/lib/libclang-cpp.dylib+0x1ac75e8)
#7 0x0000000100d775d8 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef, std::__1::allocator>>, llvm::IntrusiveRefCntPtr, bool, bool, llvm::StringRef) (/opt/homebrew/Cellar/llvm/21.1.3/bin/clang-tidy+0x1000035d8)
#8 0x0000000100da3560 clang::tidy::clangTidyMain(int, char const**) (/opt/homebrew/Cellar/llvm/21.1.3/bin/clang-tidy+0x10002f560)
#9 0x0000000190b76b98
Abort
```
Contributor guide
Research direction
Reproduce the shown clang-tidy command using the Xcode compile_commands.json instructions and inspect the ClangTool::run and runClangTidy entry points named in the stack trace. Trace how the compilation database selects the source directory, then verify that the command no longer aborts with the Cannot chdir error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100