View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008211CMakeCMakepublic2008-12-02 12:122014-06-02 08:37
ReporterDavid Karr 
Assigned ToBill Hoffman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0008211: cmTarget::setType uses this->Makefile before it is defined
DescriptionIn the function cmTarget::setType, the following lines occur:

  if(type == cmTarget::INSTALL_FILES ||
     type == cmTarget::INSTALL_PROGRAMS ||
     type == cmTarget::INSTALL_DIRECTORY)
    {
    this->Makefile->
      IssueMessage(cmake::INTERNAL_ERROR,
                   "SetType called on cmTarget for INSTALL_FILES, "
                   "INSTALL_PROGRAMS, or INSTALL_DIRECTORY ");
    return;
    }

But in the three places where cmTarget::setType is called, it is called on a newly-created cmTarget whose Makefile has not yet been set. This can be confirmed by recompiling CMake with the following lines inserted at the start of the body of cmTarget::setType

  std::cerr << name << " makefile " <<
   (this->Makefile ? "OK" : "DOES NOT EXIST") << std::endl;
  type = cmTarget::INSTALL_FILES;

This simulates the occurrence of an internal error elsewhere in CMake. When the modified copy of CMake is used to generate a typical Visual Studio 9 "solution", it crashes immediately after printing out the text indicating that the makefile "does not exist".

This problem would be masked in normal operation, because the internal error should not occur. But if the internal error ever DID occur, the error messaging code would be useless.

Calling cmTarget::setMakefile before cmTarget::setType does not appear to be a valid resolution of this error, since that function requires the cmTarget type to be set already. Passing the makefile as an additional argument to cmTarget::setType may be a viable option.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0014270)
Brad King (manager)
2008-12-02 12:40

This is why I'm a fan of constructor arguments which avoid creating objects in invalid states.

Bill, you were the one that wrote the code in question. I just had abort() there since this case is not supposed to be hit.
(0034321)
Stephen Kelly (developer)
2013-11-02 10:13

This seems to be obsolete.
(0035985)
Robert Maynard (manager)
2014-06-02 08:37

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2008-12-02 12:12 David Karr New Issue
2008-12-02 12:26 Bill Hoffman Status new => assigned
2008-12-02 12:26 Bill Hoffman Assigned To => Brad King
2008-12-02 12:40 Brad King Note Added: 0014270
2008-12-02 12:40 Brad King Assigned To Brad King => Bill Hoffman
2013-11-02 10:13 Stephen Kelly Note Added: 0034321
2013-11-02 10:13 Stephen Kelly Status assigned => resolved
2013-11-02 10:13 Stephen Kelly Resolution open => fixed
2014-06-02 08:37 Robert Maynard Note Added: 0035985
2014-06-02 08:37 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team