llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang-tidy crash with Assertion `0 && "Invalid SLocOffset or bad function choice"' failed

Open jackua22 opened this issue 2 years ago • 10 comments

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 avatar Apr 20 '24 23:04 jackua22

@jackua22: Could you please provide reproducer?

EugeneZelenko avatar Apr 21 '24 01:04 EugeneZelenko

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.

jackua22 avatar Apr 22 '24 01:04 jackua22

Could you try with https://github.com/llvm/llvm-project/pull/87433? Looks similar to https://github.com/llvm/llvm-project/issues/87303

FruitClover avatar Apr 22 '24 19:04 FruitClover

I think we have a patch for #87433.

jackua22 avatar Apr 22 '24 19:04 jackua22

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

FruitClover avatar Apr 22 '24 20:04 FruitClover

This change were delivered only to main branch.

PiotrZSL avatar Apr 22 '24 21:04 PiotrZSL

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.

jackua22 avatar Apr 23 '24 17:04 jackua22

main branch is for 19 and above

PiotrZSL avatar Apr 23 '24 17:04 PiotrZSL

Our support rebuilt LLVM 18.1.4 with the patch. No crash.

jackua22 avatar Apr 23 '24 19:04 jackua22

I guess we could close this one.

FruitClover avatar Apr 26 '24 00:04 FruitClover