View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015736CMakeModulespublic2015-09-10 13:462016-02-01 09:10
ReporterFelix Geyer 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionCMake 3.4Fixed in VersionCMake 3.4 
Summary0015736: FeatureTesting unreliable
DescriptionThe CompileFeatures test fails in Debian on the architecture alpha.
My guess is that it's a general problem and other architectures just got lucky.

The problem seems to be that Modules/Internal/FeatureTesting.cmake doesn't add a terminator (\0 or \n for example) at the start of const char features.

As a result a printable character can appear in the binary right before "${lang}_FEATURE:".
So when cmake extracts strings from the binary it reads "kC_FEATURE:1c_function_prototypes\n".
The extra "k" at the start confuses the module as it expects "C_FEATURE".

This code in Modules/Internal/FeatureTesting.cmake might be supposed to add a null character at the start:
  const char features[] = {\"\"\n")

However if I'm not mistaken C just concats string literals that are space separated -> it's a noop.

Replacing that empty string literal with "\0" fixes the problem.

Original bug report with an analysis of the problem:
https://bugs.debian.org/789807 [^]
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0039400)
Brad King (manager)
2015-09-10 14:16

Modules/CMakeDetermineCompilerId.cmake uses a similar approach but can tolerate content before and after the intended string because it does

 if("${info}" MATCHES "INFO:compiler\\[([^]\"]*)\\]")

on the "info" value extracted from the binary, which is intended to be of the form

  INFO:compiler[value]

for the value to be "value". If this is extracted with extra content such as

  xxINFO:compiler[value]xx

it will still match the value.
(0039401)
Brad King (manager)
2015-09-10 14:44

Since the <LANG>_FEATURES:... strings are all together in a single string literal in the binary we know there is nothing before or after them except for the first and last entry. We already have a trailing newline after the last entry. We can just use a leading newline before the first entry as suggested in the description.

This should fix it:

 Features: Extract strings from test binary more reliably
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=150e1b27 [^]
(0040397)
Robert Maynard (manager)
2016-02-01 09:10

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

 Issue History
Date Modified Username Field Change
2015-09-10 13:46 Felix Geyer New Issue
2015-09-10 14:02 Brad King Target Version => CMake 3.4
2015-09-10 14:16 Brad King Note Added: 0039400
2015-09-10 14:44 Brad King Note Added: 0039401
2015-09-10 14:44 Brad King Assigned To => Brad King
2015-09-10 14:44 Brad King Status new => resolved
2015-09-10 14:44 Brad King Resolution open => fixed
2015-09-10 14:44 Brad King Fixed in Version => CMake 3.4
2016-02-01 09:10 Robert Maynard Note Added: 0040397
2016-02-01 09:10 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team