Open phantom-jacob opened 4 months ago
Could you please try 18 or main
branch? https://godbolt.org should be helpful.
It looks like the seg fault is resolved if I comment out these two options in my .clang-tidy
file:
ImplementationFileExtensions: [".cpp"]
HeaderFileExtensions: [".h"]
Confirmed seg fault persists with clang-tidy-18 when using either one of these settings:
ImplementationFileExtensions: [".cpp"]
HeaderFileExtensions: [".h"]
Output:
/usr/bin/clang-tidy-18 --extra-arg-before=--driver-mode=g++ /home/jacobd/git/phantom/alchemy/libutil_v2/pretty_print.cpp -- /usr/bin/g++ -DDEV -DPHANTOM_CLOUD -I/home/jacobd/git/phantom/alchemy -I/home/jacobd/git/phantom/build/alchemy -I/home/jacobd/git/phantom/build/schema -isystem /home/jacobd/.conan/data/boost/1.83.0/_/_/package/1714959b53650488b37c41cd3a9ade3fb312129e/include -isystem /home/jacobd/.conan/data/protobuf/3.15.8/_/_/package/2174169f0a98f7948e48a1ac4492bd66e02fcec8/include -isystem /home/jacobd/.conan/data/zlib/1.3.1/_/_/package/af11149481c69e4ca43a19f2690848b74023e63e/include -Wno-unused-command-line-argument -O2 -g -DNDEBUG -fPIC -pipe -Wall -Werror -Wdelete-non-virtual-dtor -ggdb -DSHOULD_LOG_IPC -fcoroutines -std=gnu++2a -MD -MT alchemy/libutil_v2/CMakeFiles/util_v2.dir/pretty_print.cpp.o -MF alchemy/libutil_v2/CMakeFiles/util_v2.dir/pretty_print.cpp.o.d -o alchemy/libutil_v2/CMakeFiles/util_v2.dir/pretty_print.cpp.o -c /home/jacobd/git/phantom/alchemy/libutil_v2/pretty_print.cpp
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /usr/bin/clang-tidy-18 --extra-arg-before=--driver-mode=g++ /home/jacobd/git/phantom/alchemy/libutil_v2/pretty_print.cpp -- /usr/bin/g++ -DDEV -DPHANTOM_CLOUD -I/home/jacobd/git/phantom/alchemy -I/home/jacobd/git/phantom/build/alchemy -I/home/jacobd/git/phantom/build/schema -isystem /home/jacobd/.conan/data/boost/1.83.0/_/_/package/1714959b53650488b37c41cd3a9ade3fb312129e/include -isystem /home/jacobd/.conan/data/protobuf/3.15.8/_/_/package/2174169f0a98f7948e48a1ac4492bd66e02fcec8/include -isystem /home/jacobd/.conan/data/zlib/1.3.1/_/_/package/af11149481c69e4ca43a19f2690848b74023e63e/include -Wno-unused-command-line-argument -O2 -g -DNDEBUG -fPIC -pipe -Wall -Werror -Wdelete-non-virtual-dtor -ggdb -DSHOULD_LOG_IPC -fcoroutines -std=gnu++2a -MD -MT alchemy/libutil_v2/CMakeFiles/util_v2.dir/pretty_print.cpp.o -MF alchemy/libutil_v2/CMakeFiles/util_v2.dir/pretty_print.cpp.o.d -o alchemy/libutil_v2/CMakeFiles/util_v2.dir/pretty_print.cpp.o -c /home/jacobd/git/phantom/alchemy/libutil_v2/pretty_print.cpp
#0 0x00007dc41ed94716 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd94716)
#1 0x00007dc41ed926d0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd926d0)
#2 0x00007dc41ed94ddb (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd94ddb)
#3 0x00007dc41d842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00006316ff30b73c clang::tidy::ClangTidyContext::diag(llvm::StringRef, llvm::StringRef, clang::DiagnosticIDs::Level) (/usr/bin/clang-tidy-18+0x136a73c)
#5 0x00006316ff30b1ca clang::tidy::ClangTidyContext::setCurrentFile(llvm::StringRef) (/usr/bin/clang-tidy-18+0x136a1ca)
#6 0x00006316ff2fe801 clang::tidy::getCheckNames[abi:cxx11](clang::tidy::ClangTidyOptions const&, bool) (/usr/bin/clang-tidy-18+0x135d801)
#7 0x00006316fe69b46e clang::tidy::clangTidyMain(int, char const**) (/usr/bin/clang-tidy-18+0x6fa46e)
#8 0x00007dc41d829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#9 0x00007dc41d829e40 call_init ./csu/../csu/libc-start.c:128:20
#10 0x00007dc41d829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#11 0x00006316fe6980e5 _start (/usr/bin/clang-tidy-18+0x6f70e5)
[1] 600220 segmentation fault (core dumped) /usr/bin/clang-tidy-18 --extra-arg-before=--driver-mode=g++ -- /usr/bin/g++
@phantom-jacob: Could you please provide reproducer, preferably on https://godbolt.org?
Confirmed reproducible with an empty file. Seems entirely related to the config:
$ touch empty.cpp
$ clang-tidy-18 empty.cpp
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: clang-tidy-18 empty.cpp
#0 0x00007734f7594716 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd94716)
#1 0x00007734f75926d0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd926d0)
#2 0x00007734f7594ddb (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd94ddb)
#3 0x00007734f6042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00005a053e54e73c clang::tidy::ClangTidyContext::diag(llvm::StringRef, llvm::StringRef, clang::DiagnosticIDs::Level) (/usr/lib/llvm-18/bin/clang-tidy+0x136a73c)
#5 0x00005a053e54e1ca clang::tidy::ClangTidyContext::setCurrentFile(llvm::StringRef) (/usr/lib/llvm-18/bin/clang-tidy+0x136a1ca)
#6 0x00005a053e541801 clang::tidy::getCheckNames[abi:cxx11](clang::tidy::ClangTidyOptions const&, bool) (/usr/lib/llvm-18/bin/clang-tidy+0x135d801)
#7 0x00005a053d8de46e clang::tidy::clangTidyMain(int, char const**) (/usr/lib/llvm-18/bin/clang-tidy+0x6fa46e)
#8 0x00007734f6029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#9 0x00007734f6029e40 call_init ./csu/../csu/libc-start.c:128:20
#10 0x00007734f6029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#11 0x00005a053d8db0e5 _start (/usr/lib/llvm-18/bin/clang-tidy+0x6f70e5)
[1] 604354 segmentation fault (core dumped) clang-tidy-18 empty.cpp
Okay, narrowed it down even further. It appears to work if I remove the .
characters from the extension lists. Either of these settings will cause clang-tidy to crash:
ImplementationFileExtensions: [".cpp"]
HeaderFileExtensions: [".h"]
But with a small edit, clang-tidy accepts the config and no longer crashes:
ImplementationFileExtensions: ["cpp"]
HeaderFileExtensions: ["h"]
So, in all it's probably a fairly minor issue, but it could handle the invalid config more gracefully
Crash is because when emitting warning "Invalid header file extensions" diagnostic engine is not set, and because of that we got nullptr dereference. This isn't easy to fix.
Ubuntu 22.04, g++-10, LLVM 17:
Using this clang-tidy config: