codeql stuck for 30+ minutes during FindHDF5.cmake execution
- Dominant language
- CodeQL
- Stars
- 10.1k
- Forks
- 2.1k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 141
Description
On a Ubuntu 20.04 host with the following CMakeLists.txt:
```
cmake_minimum_required(VERSION 3.16)
project(gdal LANGUAGES C CXX)
find_package(HDF5 COMPONENTS C CXX)
```
and package libhdf5-dev installed
running "cmake .." takes more than half an hour
Verbose output:
```
$ cmake .. --debug-output
Running with debug output on.
-- The C compiler identification is GNU 9.4.0
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- The CXX compiler identification is GNU 9.4.0
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeDetermineCXXCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Check for working C compiler: /usr/bin/cc
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeTestCompilerCommon.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Check for working C compiler: /usr/bin/cc -- works
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeTestCompilerCommon.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Detecting C compiler ABI info
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerABI.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Detecting C compiler ABI info - done
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerABI.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Detecting C compile features
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompileFeatures.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Detecting C compile features - done
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompileFeatures.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Check for working CXX compiler: /usr/bin/c++
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeTestCompilerCommon.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Check for working CXX compiler: /usr/bin/c++ -- works
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeTestCompilerCommon.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Detecting CXX compiler ABI info
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerABI.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Detecting CXX compiler ABI info - done
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerABI.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Detecting CXX compile features
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompileFeatures.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- Detecting CXX compile features - done
Called from: [3] /usr/share/cmake-3.16/Modules/CMakeDetermineCompileFeatures.cmake
[2] /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
Called from: [2] /usr/share/cmake-3.16/Modules/FindHDF5.cmake
[1] /home/even/gdal/gdal/build_cmake/tmptmphdf5/CMakeLists.txt
```
Relevant processes that take ages to complete:
```
even 3102981 3694545 1 02:30 pts/8 00:00:00 cmake .. --debug-output
even 3103156 3102981 0 02:30 pts/8 00:00:00 /bin/sh /usr/bin/h5c++ -show -shlib /home/even/gdal/gdal/build_cmake/tmptmphdf5/build/CMakeFiles/hdf5/cmake_hdf5_test.cxx
even 3103177 3103156 11 02:30 pts/8 00:00:01 /home/even/gdal/gdal/build_cmake/codeql/cpp/tools/linux64/extractor --mimic /usr/bin/h5c++ -show -shlib /home/even/gdal/gdal/build_cmake/tmptmphdf5/bui
even 3103178 3103177 0 02:30 pts/8 00:00:00 /bin/sh /usr/bin/h5c++ -x c++ -v -fsyntax-only /home/even/gdal/gdal/build_cmake/codeql_databases/cpp/working/tmp//semmle_1_3103177_195397
even 3103179 3103178 0 02:30 pts/8 00:00:00 /bin/sh /usr/bin/h5c++ -x c++ -v -fsyntax-only /home/even/gdal/gdal/build_cmake/codeql_databases/cpp/working/tmp//semmle_1_3103177_195397
even 3103198 3103179 0 02:30 pts/8 00:00:00 g++ -I/usr/include/hdf5/serial -x c++ -v -fsyntax-only /home/even/gdal/gdal/build_cmake/codeql_databases/cpp/working/tmp//semmle_1_3103177_195397 -L/us
even 3103199 3103198 0 02:30 pts/8 00:00:00 g++ -I/usr/include/hdf5/serial -x c++ -v -fsyntax-only /home/even/gdal/gdal/build_cmake/codeql_databases/cpp/working/tmp//semmle_1_3103177_195397 -L/us
even 3103224 3103199 0 02:30 pts/8 00:00:00 /usr/lib/gcc/x86_64-linux-gnu/9/cc1plus -quiet -v -I /usr/include/hdf5/serial -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /usr/lib/x86_64-linux-gnu/hdf5
even 3103225 3103224 0 02:30 pts/8 00:00:00 /usr/lib/gcc/x86_64-linux-gnu/9/cc1plus -quiet -v -I /usr/include/hdf5/serial -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /usr/lib/x86_64-linux-gnu/hdf5
```
(originally diagnosed in https://github.com/OSGeo/gdal/issues/9549)
Contributor guide
Research direction
Start with the FindHDF5.cmake invocation that runs the h5c++ compiler wrapper, using the supplied CMakeLists.txt on Ubuntu 20.04 as the reproduction. Inspect the CodeQL C++ extractor process and its compiler-wrapper command shown in the report. Done means cmake completes the HDF5 detection without remaining stuck for more than 30 minutes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100