CMake 3.24.20220710-g8a32a96d crashes on configuring Qt
How to reproduce:
Build CMake's master branch. Configure Qt's qtbase repository (git://code.qt.io/qt/qtbase.git) with it on any platform like this:
cmake ~/dev/qt/dev/qtbase -G Ninja
This will crash:
-- The CXX compiler identification is GNU 10.2.1
-- The C compiler identification is GNU 10.2.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
Segmentation fault
Backtrace: backtrace.txt
We dereference a null pointer in bool cmExportSet::Compute
:
(gdb) p tgtExport->Target
$1 = (cmGeneratorTarget *) 0x0
The commit that introduced this crash is
3fee5398bd381e3721972220a8415b62bc96b172 is the first bad commit
commit 3fee5398bd381e3721972220a8415b62bc96b172
Author: Kyle Edwards <kyle.edwards@kitware.com>
Date: Tue Jun 28 14:15:19 2022 -0400
install(EXPORT): Check for missing file sets at generate time
Missing file sets were originally checked at configure time in
install(TARGETS ... EXPORT), but were not checked at generate time. If
a file set was added after install(TARGETS ... EXPORT) was called,
an abortion error was thrown. Check again at generate time to gracefully
display an error message instead of crashing.
Fixes: #23680
Source/cmExportSet.cxx | 31 +++++++++++++++++++++-
Source/cmExportSet.h | 2 +-
Source/cmInstallExportGenerator.cxx | 3 +--
...ExportMissingSetsInterfacePostExport-result.txt | 1 +
...ExportMissingSetsInterfacePostExport-stderr.txt | 6 +++++
...leSetExportMissingSetsInterfacePostExport.cmake | 6 +++++
...stallMissingSetsInterfacePostInstall-result.txt | 1 +
...stallMissingSetsInterfacePostInstall-stderr.txt | 6 +++++
...SetInstallMissingSetsInterfacePostInstall.cmake | 6 +++++
Tests/RunCMake/target_sources/RunCMakeTest.cmake | 2 ++
10 files changed, 60 insertions(+), 4 deletions(-)
create mode 100644 Tests/RunCMake/target_sources/FileSetExportMissingSetsInterfacePostExport-result.txt
create mode 100644 Tests/RunCMake/target_sources/FileSetExportMissingSetsInterfacePostExport-stderr.txt
create mode 100644 Tests/RunCMake/target_sources/FileSetExportMissingSetsInterfacePostExport.cmake
create mode 100644 Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterfacePostInstall-result.txt
create mode 100644 Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterfacePostInstall-stderr.txt
create mode 100644 Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterfacePostInstall.cmake
bisect run success