Skip to content

[clang-tidy] Crash with readability-non-const-parameter and K&R declarations #100340

Closed
@mkmvzlb

Description

@mkmvzlb

The simple legacy C-code below crashes clang-tidy, at least version 10, 12 and 16:

static int f();

int f(p)
  int *p;
{
    return *p;
}

Stack:

$ clang-tidy -checks=-,readability-non-const-parameter legacy.c
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "legacy.c"
No compilation database found in /home/michael/Projects/clang-tidy-bug or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
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 -checks=-,readability-non-const-parameter legacy.c
1.      <eof> parser at end of file
2.      ASTMatcher: Not currently matching
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM-16.so.1    0x00007f9df79c975a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 58
1  libLLVM-16.so.1    0x00007f9df79c7994 llvm::sys::RunSignalHandlers() + 84
2  libLLVM-16.so.1    0x00007f9df79c9f2b
3  libc.so.6          0x00007f9df6242990
4  clang-tidy         0x00005f814fa1e5d9 clang::tidy::readability::NonConstParameterCheck::diagnoseNonConstParameters() + 249
5  clang-tidy         0x00005f814fa60192 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) + 914
6  libclang-cpp.so.16 0x00007f9e00a5771c clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) + 44
7  libclang-cpp.so.16 0x00007f9dfedddf32 clang::ParseAST(clang::Sema&, bool, bool) + 850
8  libclang-cpp.so.16 0x00007f9e00a1d2a9 clang::FrontendAction::Execute() + 89
9  libclang-cpp.so.16 0x00007f9e00998184 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 724
10 libclang-cpp.so.16 0x00007f9e00c34555 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) + 389
11 clang-tidy         0x00005f814ffd3226
12 libclang-cpp.so.16 0x00007f9e00c342e2 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) + 290
13 libclang-cpp.so.16 0x00007f9e00c33311 clang::tooling::ToolInvocation::run() + 1329
14 libclang-cpp.so.16 0x00007f9e00c35bb2 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) + 3842
15 clang-tidy         0x00005f814ffcf249 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) + 1049
16 clang-tidy         0x00005f814f3497ea clang::tidy::clangTidyMain(int, char const**) + 10474
17 libc.so.6          0x00007f9df6228150
18 libc.so.6          0x00007f9df6228209 __libc_start_main + 137
19 clang-tidy         0x00005f814f344c35 _start + 37
zsh: segmentation fault (core dumped)  clang-tidy -checks=-,readability-non-const-parameter legacy.c

Metadata

Metadata

Assignees

Labels

clang-tidycrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions