View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0016044CMakeCMakepublic2016-04-01 05:572016-06-10 14:21
ReporterGianfranco 
Assigned ToBrad King 
PriorityhighSeveritycrashReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformLinuxOSUbuntuOS Version16.04
Product VersionCMake 3.5.1 
Target VersionCMake 3.5.2Fixed in VersionCMake 3.5.2 
Summary0016044: cmake crashed with SIGSEGV in cmTarget::GetProperty()
Descriptionhttps://bugs.launchpad.net/ubuntu/+source/cmake/+bug/1564741 [^]

As reported on the Ubuntu bug, the culprit seems to be commit a67231ac114235f0af4673235c4c07fa896c8ab6.
Tagspatch
Attached Filespatch file icon 0001-Prevent-SIGSEGV-when-ALIASing-a-target-defined-in-an.patch [^] (14,036 bytes) 2016-04-01 08:30 [Show Content]

 Relationships
has duplicate 0016048closed Segfault on target_link_libraries() with aliased target from another subdirectory 

  Notes
(0040787)
Gianfranco (reporter)
2016-04-01 05:57

cmTarget::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cmMakefile*) const ()
 cmGetTargetPropertyCommand::InitialPass(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, cmExecutionStatus&) ()
 cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&) ()
 cmForEachFunctionBlocker::IsFunctionBlocked(cmListFileFunction const&, cmMakefile&, cmExecutionStatus&) ()
 cmMakefile::IsFunctionBlocked(cmListFileFunction const&, cmExecutionStatus&) ()
Title: cmake crashed with SIGSEGV in cmTarget::GetProperty()
(0040788)
Matteo Settenvini (reporter)
2016-04-01 08:31

Hallo, I am the original reporter. Attached is a patch fixing the problem for me. It includes a test case.
(0040790)
Brad King (manager)
2016-04-01 09:44

Re 0016044:0040788: Thanks for tracking it down! This should fix it:

 Fix lookup of an ALIAS target outside aliased target's directory
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=275a7c26 [^]

I included your test case too.

I've queued this for merge to 'release' for inclusion in 3.5.2.
(0040792)
Matteo Settenvini (reporter)
2016-04-01 10:01

Thanks Brad, that was quick!

I am afraid though that it is still not enough. I am having another segfault with your commit at the end of the configuration process, that I do not have with mine.

It is due to the implementation of:
cmLocalGenerator::FindGeneratorTarget(const std::string& name) const

On return, it does not check if an alias is really present before dereferencing the iterator.

You can take a fix directly from my patch, which saves some lines of code too :-).

Cheers!
(0040794)
Brad King (manager)
2016-04-01 10:08

Re 0016044:0040792: Thanks for testing it. Can you provide a test case for that crash too?
(0040795)
Matteo Settenvini (reporter)
2016-04-01 10:23

Not yet, although not for wont of trying. We have a big project with ~7'000 cmake code lines, which definitely triggers this, but I've been unable to boil it down to a simple use case.

However, it does definitely breaks all our builds, so we're already patching CMake on our side. The fix should be relatively harmless, though, as one can see that FindGeneratorTarget potentially dereferences an invalid iterator.

I'll try to come up with something, but it was escalated to a low priority task on my side, so it might take some time.
(0040796)
Brad King (manager)
2016-04-01 10:41

Re 0016044:0040795: Okay, thanks. We can add the generate-step test case later when you produce it.

I've revised the fix:

 Fix lookup of an ALIAS target outside aliased target's directory
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e1eae2a3 [^]

Then I followed it up with another commit to help avoid re-introducing the incorrect alias lookup later:

 Rename local target lookup methods to clarify purpose
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e47ec3c9 [^]
(0040800)
Brad King (manager)
2016-04-01 15:46

Thanks to a second report of this issue in 0016048 with another test case I was able to improve the test case to cover the cmLocalGenerator part of this fix too. Here is a revised fix:

 Fix lookup of an ALIAS target outside aliased target's directory
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc30f8b5 [^]

 Rename local target lookup methods to clarify purpose
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e44f489 [^]
(0040801)
Matteo Settenvini (reporter)
2016-04-04 03:19

Thanks again Brad, the last commits you posted fix the problem for me.
(0041203)
Kitware Robot (administrator)
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.

 Issue History
Date Modified Username Field Change
2016-04-01 05:57 Gianfranco New Issue
2016-04-01 05:57 Gianfranco Note Added: 0040787
2016-04-01 08:30 Matteo Settenvini File Added: 0001-Prevent-SIGSEGV-when-ALIASing-a-target-defined-in-an.patch
2016-04-01 08:31 Matteo Settenvini Note Added: 0040788
2016-04-01 08:31 Matteo Settenvini Tag Attached: patch
2016-04-01 09:44 Brad King Note Added: 0040790
2016-04-01 09:44 Brad King Assigned To => Brad King
2016-04-01 09:44 Brad King Status new => resolved
2016-04-01 09:44 Brad King Resolution open => fixed
2016-04-01 09:44 Brad King Fixed in Version => CMake 3.5.2
2016-04-01 09:44 Brad King Target Version => CMake 3.5.2
2016-04-01 10:01 Matteo Settenvini Note Added: 0040792
2016-04-01 10:07 Brad King Status resolved => assigned
2016-04-01 10:07 Brad King Resolution fixed => reopened
2016-04-01 10:07 Brad King Fixed in Version CMake 3.5.2 =>
2016-04-01 10:08 Brad King Note Added: 0040794
2016-04-01 10:23 Matteo Settenvini Note Added: 0040795
2016-04-01 10:41 Brad King Note Added: 0040796
2016-04-01 10:43 Brad King Status assigned => resolved
2016-04-01 10:43 Brad King Resolution reopened => fixed
2016-04-01 10:43 Brad King Fixed in Version => CMake 3.5.2
2016-04-01 15:30 Brad King Relationship added has duplicate 0016048
2016-04-01 15:46 Brad King Note Added: 0040800
2016-04-04 03:19 Matteo Settenvini Note Added: 0040801
2016-06-10 14:21 Kitware Robot Note Added: 0041203
2016-06-10 14:21 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team