Skip to content

Clang-Tidy fails when I include PQXX library #139286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cla-db opened this issue May 9, 2025 · 4 comments
Closed

Clang-Tidy fails when I include PQXX library #139286

cla-db opened this issue May 9, 2025 · 4 comments
Labels
clang-tidy crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@cla-db
Copy link

cla-db commented May 9, 2025

My project uses clang-tidy with no issues. Recently I added to PQXX library (https://pqxx.org/libpqxx/) to connect to a Postgres database and since then clang-tidy fails.

I can confirm that simply including the library causes the failure, no matter what the code does with that library (even nothing).

Steps to reproduce:

  1. Instal the PQXX library on the system
  2. Add #include <pqxx/pqxx> to a .cpp file
  3. Run clang-tidy on that file

Stack trace:

0. Program arguments: clang-tidy --extra-arg-before=--driver-mode=g++ /home/claudio/dev/HOS/data_reader/src/process_variables.cpp -- /usr/bin/c++ -I/usr/include/postgresql -I/home/claudio/dev/HOS/data_reader/src -std=c++20 -std=gnu++20 -Wall -Wextra -Wpedantic -Werror -MD -MT CMakeFiles/data_reader.dir/src/process_variables.cpp.o -MF CMakeFiles/data_reader.dir/src/process_variables.cpp.o.d -o CMakeFiles/data_reader.dir/src/process_variables.cpp.o -c /home/claudio/dev/HOS/data_reader/src/process_variables.cpp
1.      <eof> parser at end of file
2.      ASTMatcher: Processing 'altera-id-dependent-backward-branch' against:
        WhileStmt : </usr/include/pqxx/internal/encodings.hxx:219:3, line:220:51>
--- Bound Nodes Begin ---
    backward_branch - { WhileStmt : </usr/include/pqxx/internal/encodings.hxx:219:3, line:220:51> }
    cond_expr - { CXXFoldExpr : </usr/include/pqxx/internal/encodings.hxx:219:10, col:41> }
--- Bound Nodes End ---
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.so.18.1      0x00007fe015f623bf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63
1  libLLVM.so.18.1      0x00007fe015f604f9 llvm::sys::RunSignalHandlers() + 89
2  libLLVM.so.18.1      0x00007fe015f62b00
3  libc.so.6            0x00007fe014c80330
4  clang-tidy           0x00005577373c7d80 clang::tidy::altera::IdDependentBackwardBranchCheck::hasIdDepVar(clang::Expr const*) + 224
5  clang-tidy           0x00005577373c90eb clang::tidy::altera::IdDependentBackwardBranchCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) + 715
6  clang-tidy           0x00005577379a9f15
7  clang-tidy           0x00005577379dd00c clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) + 156
8  clang-tidy           0x00005577379a965f
9  clang-tidy           0x00005577379d3d91
10 clang-tidy           0x00005577379bb623
11 clang-tidy           0x00005577379dbfa2
12 clang-tidy           0x00005577379af586
13 clang-tidy           0x00005577379ac66f
14 clang-tidy           0x00005577379b2ec1
15 clang-tidy           0x00005577379aca17
16 clang-tidy           0x00005577379ae96b
17 clang-tidy           0x00005577379ac747
18 clang-tidy           0x00005577379ae96b
19 clang-tidy           0x00005577379ac747
20 clang-tidy           0x00005577379d96eb
21 clang-tidy           0x00005577379acb89
22 clang-tidy           0x00005577379ac213
23 clang-tidy           0x000055773797e825 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) + 709
24 libclang-cpp.so.18.1 0x00007fe01f209fbc clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) + 44
25 libclang-cpp.so.18.1 0x00007fe01d35e3d6 clang::ParseAST(clang::Sema&, bool, bool) + 598
26 libclang-cpp.so.18.1 0x00007fe01f1cd62c clang::FrontendAction::Execute() + 92
27 libclang-cpp.so.18.1 0x00007fe01f14a0b4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 708
28 libclang-cpp.so.18.1 0x00007fe01f3c16b9 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) + 425
29 clang-tidy           0x0000557737ffdab3
30 libclang-cpp.so.18.1 0x00007fe01f3c1414 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) + 292
31 libclang-cpp.so.18.1 0x00007fe01f3c017f clang::tooling::ToolInvocation::run() + 1231
32 libclang-cpp.so.18.1 0x00007fe01f3c31c1 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) + 5041
33 clang-tidy           0x0000557737ff9d9b 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) + 1083
34 clang-tidy           0x0000557737379c65 clang::tidy::clangTidyMain(int, char const**) + 10005
35 libc.so.6            0x00007fe014c651ca
36 libc.so.6            0x00007fe014c6528b __libc_start_main + 139
37 clang-tidy           0x0000557737374fe5 _start + 37
Segmentation fault
@llvmbot
Copy link
Member

llvmbot commented May 9, 2025

@llvm/issue-subscribers-clang-tidy

Author: Claudio (cla-db)

My project uses clang-tidy with no issues. Recently I added to PQXX library (https://pqxx.org/libpqxx/) to connect to a Postgres database and since then clang-tidy fails.

I can confirm that simply including the library causes the failure, no matter what the code does with that library (even nothing).

Steps to reproduce:

  1. Instal the PQXX library on the system
  2. Add #include &lt;pqxx/pqxx&gt; to a .cpp file
  3. Run clang-tidy on that file

Stack trace:

0. Program arguments: clang-tidy --extra-arg-before=--driver-mode=g++ /home/claudio/dev/HOS/data_reader/src/process_variables.cpp -- /usr/bin/c++ -I/usr/include/postgresql -I/home/claudio/dev/HOS/data_reader/src -std=c++20 -std=gnu++20 -Wall -Wextra -Wpedantic -Werror -MD -MT CMakeFiles/data_reader.dir/src/process_variables.cpp.o -MF CMakeFiles/data_reader.dir/src/process_variables.cpp.o.d -o CMakeFiles/data_reader.dir/src/process_variables.cpp.o -c /home/claudio/dev/HOS/data_reader/src/process_variables.cpp
1.      &lt;eof&gt; parser at end of file
2.      ASTMatcher: Processing 'altera-id-dependent-backward-branch' against:
        WhileStmt : &lt;/usr/include/pqxx/internal/encodings.hxx:219:3, line:220:51&gt;
--- Bound Nodes Begin ---
    backward_branch - { WhileStmt : &lt;/usr/include/pqxx/internal/encodings.hxx:219:3, line:220:51&gt; }
    cond_expr - { CXXFoldExpr : &lt;/usr/include/pqxx/internal/encodings.hxx:219:10, col:41&gt; }
--- Bound Nodes End ---
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.so.18.1      0x00007fe015f623bf llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) + 63
1  libLLVM.so.18.1      0x00007fe015f604f9 llvm::sys::RunSignalHandlers() + 89
2  libLLVM.so.18.1      0x00007fe015f62b00
3  libc.so.6            0x00007fe014c80330
4  clang-tidy           0x00005577373c7d80 clang::tidy::altera::IdDependentBackwardBranchCheck::hasIdDepVar(clang::Expr const*) + 224
5  clang-tidy           0x00005577373c90eb clang::tidy::altera::IdDependentBackwardBranchCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&amp;) + 715
6  clang-tidy           0x00005577379a9f15
7  clang-tidy           0x00005577379dd00c clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) + 156
8  clang-tidy           0x00005577379a965f
9  clang-tidy           0x00005577379d3d91
10 clang-tidy           0x00005577379bb623
11 clang-tidy           0x00005577379dbfa2
12 clang-tidy           0x00005577379af586
13 clang-tidy           0x00005577379ac66f
14 clang-tidy           0x00005577379b2ec1
15 clang-tidy           0x00005577379aca17
16 clang-tidy           0x00005577379ae96b
17 clang-tidy           0x00005577379ac747
18 clang-tidy           0x00005577379ae96b
19 clang-tidy           0x00005577379ac747
20 clang-tidy           0x00005577379d96eb
21 clang-tidy           0x00005577379acb89
22 clang-tidy           0x00005577379ac213
23 clang-tidy           0x000055773797e825 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&amp;) + 709
24 libclang-cpp.so.18.1 0x00007fe01f209fbc clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&amp;) + 44
25 libclang-cpp.so.18.1 0x00007fe01d35e3d6 clang::ParseAST(clang::Sema&amp;, bool, bool) + 598
26 libclang-cpp.so.18.1 0x00007fe01f1cd62c clang::FrontendAction::Execute() + 92
27 libclang-cpp.so.18.1 0x00007fe01f14a0b4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) + 708
28 libclang-cpp.so.18.1 0x00007fe01f3c16b9 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr&lt;clang::CompilerInvocation&gt;, clang::FileManager*, std::shared_ptr&lt;clang::PCHContainerOperations&gt;, clang::DiagnosticConsumer*) + 425
29 clang-tidy           0x0000557737ffdab3
30 libclang-cpp.so.18.1 0x00007fe01f3c1414 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr&lt;clang::CompilerInvocation&gt;, std::shared_ptr&lt;clang::PCHContainerOperations&gt;) + 292
31 libclang-cpp.so.18.1 0x00007fe01f3c017f clang::tooling::ToolInvocation::run() + 1231
32 libclang-cpp.so.18.1 0x00007fe01f3c31c1 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) + 5041
33 clang-tidy           0x0000557737ff9d9b clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&amp;, clang::tooling::CompilationDatabase const&amp;, llvm::ArrayRef&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;&gt;, llvm::IntrusiveRefCntPtr&lt;llvm::vfs::OverlayFileSystem&gt;, bool, bool, llvm::StringRef) + 1083
34 clang-tidy           0x0000557737379c65 clang::tidy::clangTidyMain(int, char const**) + 10005
35 libc.so.6            0x00007fe014c651ca
36 libc.so.6            0x00007fe014c6528b __libc_start_main + 139
37 clang-tidy           0x0000557737374fe5 _start + 37
Segmentation fault

@EugeneZelenko EugeneZelenko added the crash Prefer [crash-on-valid] or [crash-on-invalid] label May 9, 2025
@vbvictor
Copy link
Contributor

vbvictor commented May 9, 2025

This is fixed in clang-tidy-20 (but not in 19th)

Test file:

#include <pqxx/pqxx>

int main() {}

Command run:
clang-tidy-20 --checks=* --extra-arg='-frtti' libpg.cpp

Clang-tidy version:

Ubuntu LLVM version 20.1.5
  Optimized build.

@vbvictor
Copy link
Contributor

vbvictor commented May 10, 2025

Could you please confirm there is no issue with clang-tidy-20?

@cla-db
Copy link
Author

cla-db commented May 12, 2025

Confirmed: the issue is resolved with clang-tidy-20.
Thank you for the speedy response!

@cla-db cla-db closed this as completed May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

4 participants