MantisBT - CMake
View Issue Details
0016048CMakeCMakepublic2016-04-01 15:222016-06-10 14:21
arlbranch 
 
highcrashalways
closedduplicate 
x86_64Linux4.4.5-1-ARCH
CMake 3.5.1 
 
0016048: Segfault on target_link_libraries() with aliased target from another subdirectory
CMake crashes with a segfault when target_link_libraries is used to add a dependency on an alias of a target that was added in a different subdirectory.

Complete Example
================
[branch@fortuna on /dev/pts/1] 1150 ~/repositories/test/cmake_segfault
$ cmake --version
cmake version 3.5.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[branch@fortuna on /dev/pts/1] 1151 ~/repositories/test/cmake_segfault
$ ls -lR
.:
total 12
drwxr-xr-x 2 branch atlsdd 4096 Apr 1 13:37 alib/
drwxr-xr-x 2 branch atlsdd 4096 Apr 1 14:14 blib/
-rw-r--r-- 1 branch atlsdd 98 Apr 1 13:18 CMakeLists.txt

./alib:
total 4
-rw-r--r-- 1 branch atlsdd 87 Apr 1 13:24 CMakeLists.txt

./blib:
total 4
-rw-r--r-- 1 branch atlsdd 162 Apr 1 13:38 CMakeLists.txt
[branch@fortuna on /dev/pts/1] 1152 ~/repositories/test/cmake_segfault
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
project(top)
add_subdirectory(alib)
add_subdirectory(blib)
[branch@fortuna on /dev/pts/1] 1153 ~/repositories/test/cmake_segfault
$ cat alib/CMakeLists.txt
add_library(alib alib.c)
set_source_files_properties(alib.c PROPERTIES GENERATED TRUE)
[branch@fortuna on /dev/pts/1] 1154 ~/repositories/test/cmake_segfault
$ cat blib/CMakeLists.txt
add_library(blib blib.c)
set_source_files_properties(blib.c PROPERTIES GENERATED TRUE)

add_library(alib::alib ALIAS alib)
target_link_libraries(blib alib::alib)
[branch@fortuna on /dev/pts/1] 1155 ~/repositories/test/cmake_segfault
$ mkdir build && cd build
[branch@fortuna on /dev/pts/1] 1156 ~/repositories/test/cmake_segfault/build
$ cmake ..
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Segmentation fault (core dumped)
1) create the project in the Description
2) run cmake against it
Also seen on MacOS.

This is a regression, cmake 3.4 does not crash.
No tags attached.
duplicate of 0016044closed Brad King cmake crashed with SIGSEGV in cmTarget::GetProperty() 
Issue History
2016-04-01 15:22arlbranchNew Issue
2016-04-01 15:30Brad KingRelationship addedduplicate of 0016044
2016-04-01 15:30Brad KingNote Added: 0040798
2016-04-01 15:43Brad KingNote Added: 0040799
2016-04-01 15:43Brad KingStatusnew => resolved
2016-04-01 15:43Brad KingResolutionopen => duplicate
2016-06-10 14:21Kitware RobotNote Added: 0041204
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040798)
Brad King   
2016-04-01 15:30   
This looks the same as 0016044. Please try the fix linked in 0016044:0040796.
(0040799)
Brad King   
2016-04-01 15:43   
Thanks for the small test case. This helped me improve testing for the fix in 0016044. I'll follow-up with a note about it there.
(0041204)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.