[CMake] A cmake-2.4.3 segfault that is caused by a circular chain of library dependencies

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Sep 20 23:10:15 EDT 2006


Today I inadvertently formed an unwanted circular chain of library
dependencies with the target_link_libraries command, and as a result CMake
segfaulted.

Here is a simple way you can reproduce this segfault (at least for
cmake-2.4.3 that was built and installed on a Ubuntu Dapper platform).

software at starling> cat ../test_cmake/CMakeLists.txt
project(test)
add_library(hello SHARED hello.c)
add_library(hello1 SHARED hello.c)
target_link_libraries(hello hello1)
target_link_libraries(hello1 hello)

Note the circular chain of library dependencies (hello depends on hello1 and
hello1 depends on hello) that is created by the two target_link_libraries
commands.  The result is a cmake segfault.

software at starling> cmake ../test_cmake
-- Check for working C compiler: gcc
-- Check for working C compiler: gcc -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: c++
-- Check for working CXX compiler: c++ -- works
-- Configuring done
-- Generating done
Segmentation fault

The segfault disappears, one additional "-- Build files have been written
to:..." line is emitted by the cmake command, and the created Makefiles work
fine, if you drop either of the above target_link_libraries statements to
break the circular chain of library dependencies.

Would it be straightforward to change CMake so it responded more gracefully
to circular library dependencies?  I hate enigmatic segfault responses to
user errors since they waste a lot of time.  For example, for the much more
complex PLplot build it took me several hours to realize the segfault was
generated by a circular chain of library dependencies that I had created by
mistake.

Note this particular segfault does not seem to have anything to do with bad
memory management.  A valgrind run sailed through without any error messages
until the same segfault message that stopped the cmake command without
valgrind.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list