clang-tidy crash with Assertion `0 && "Invalid SLocOffset or bad function choice"' failed
clang-tidy llvm-v18.1.4 crashes with similar stacks but different headers, see three attachments. ua_Compiler_sideFile_src_swfvDB.C.log ua_Debug_uart_src_uart_ckpt_sr.C.log ua_Jupiter_beDB_src_ffDB.C.log
@jackua22: Could you please provide reproducer?
I reproduced the issue with one line
#include <sparsehash/dense_hash_map>
The header is from here:
https://github.com/sparsehash/sparsehash/releases/tag/sparsehash-2.0.4
To reproduce:
/grid/common/test/llvm-v18.1.4d1rh74_lnx86/bin/clang -c -std=c++17 -stdlib=libc++ -O3 -I/grid/cva/p4/eugene/z1/ua/3party/sparsehash/include tmp.cpp
/grid/common/test/llvm-v18.1.4d1rh74_lnx86/bin/clang-tidy '--checks=-*,modernize-loop-convert,modernize-make-shared,modernize-make-unique,readability-duplicate-include' -- -std=c++17 -stdlib=libc++ -I/grid/cva/p4/eugene/z1/ua/3party/sparsehash/include
The first command is to prove that the code is compilable, and the second reproduces the crash. The crash is from readability-duplicate-include, but the first three checks change the depth of the crash stack (any of them), which requires some attention too.
The error message is:
1. /.../sparsehash/include/sparsehash/dense_hash_map:106:2: current parser token 'include'
2. /.../sparsehash/include/sparsehash/internal/densehashtable.h:105:1 <Spelling=/.../sparsehash/include/sparsehash/internal/sparseconfig.h:46:34>: parsing namespace 'google'
#0 0x000000000418186b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/grid/common/test/llvm-v18.1.4d1rh74_lnx86/bin/clang-tidy+0x418186b)
#1 0x000000000417ebbb llvm::sys::RunSignalHandlers() (/grid/common/test/llvm-v18.1.4d1rh74_lnx86/bin/clang-tidy+0x417ebbb)
#2 0x000000000417ece5 SignalHandler(int) Signals.cpp:0:0
Line 46 from that file is:
#define _START_GOOGLE_NAMESPACE_ namespace google {
It is the last line in the file.
Could you try with https://github.com/llvm/llvm-project/pull/87433? Looks similar to https://github.com/llvm/llvm-project/issues/87303
I think we have a patch for #87433.
I think we have a patch for #87433.
Hm, I don't see any tags at https://github.com/llvm/llvm-project/commit/ed4e505c219fe6c7464ea5a056e90d8cd94c7332 commit, and https://github.com/llvm/llvm-project/blob/llvmorg-18.1.4/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp in 18.1.4 has no such patch, so looks like it's not included in mentioned binaries
This change were delivered only to main branch.
The main branch is for 18.2, 19.1 or 20.1? And, is it truly the same as another? I spent hours creating a minimal test case, as I was asked to do. I suspect trying my case is faster than applying a patch and rebuilding LLVM in our house.
main branch is for 19 and above
Our support rebuilt LLVM 18.1.4 with the patch. No crash.
I guess we could close this one.