View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0009093CMakeModulespublic2009-06-02 06:072010-09-09 23:50
ReporterMarcel Loose 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilitysometimes
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionCMake 2.8.3Fixed in VersionCMake 2.8.3 
Summary0009093: FindMPI sometimes fails because it checks for non-existing libraries
DescriptionFindMPI sometimes fails because it checks for non-existing libraries. This happens when the variable MPI_LIBNAMES contains strings that contain a "-l", which are not library names.

For example: "/bgsys/drivers/V1R3M0_460_2008-081112P/ppc/gnu-linux/bin/powerpc-bgp-linux-g++" produces "inux/bin/powerpc-bgp-linux-g++" as library name to check for.

The culprit is in line 205 of FindMPI.cmake:
string(REGEX MATCHALL "-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")

I don't know how this can be solved elegantly with the limited regex support in CMake. With full regex support I would probably try to use a word-boundary check.
TagsNo tags attached.
Attached Filespatch file icon FindMPI.cmake.patch [^] (3,481 bytes) 2009-06-03 04:16 [Show Content]
? file icon FindMPI.cmake.patch2 [^] (3,750 bytes) 2009-10-22 09:30
patch file icon 0001-FindMPI-Parse-mpicc-flags-more-carefully-9093.patch [^] (2,836 bytes) 2010-06-25 09:11 [Show Content]

 Relationships
has duplicate 0010312closedBrad King FindMPI.cmake fails for path name containing "-l" 

  Notes
(0016608)
Marcel Loose (developer)
2009-06-02 17:37

This bug is not limited to the libraries specified using -l. Also the preprocessor defines -D, the include paths -I, the library paths -L, and to a lesser extent the linker options -Wl, are vulnarable.

The quick and dirty fix I can come up with is to prepend a space character to both MPI_COMPILE_CMDLINE and MPI_LINK_CMDLINE, and search for a matching "^ -l", instead of "^-l" (and similar for the -D, -I, -L, and -Wl, cases).
(0016609)
Marcel Loose (developer)
2009-06-03 04:16

I've uploaded a patch that implements the quick and dirty fix described above. This patch is NOT heavily tested!
(0018174)
Marcel Loose (developer)
2009-10-22 09:30

Though not directly related to this bug, I've updated the patch so that FindMPI also sets MPI_INCLUDE_DIRS, as required by current standards.
(0021160)
Alex Neundorf (developer)
2010-06-24 17:10

If I see it correctly Brad committed a fix for this today to branch next.

Alex
(0021161)
Brad King (manager)
2010-06-24 17:12

I did, and the fix is here:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=68c7d3e2 [^]

I didn't know about this issue until now or I would have referenced it.
(0021164)
Marcel Loose (developer)
2010-06-25 04:13

Brad's fix only applies to the "-l" case. Though I haven't encountered issues with -I, -D, -L, and -Wl, these regexes in principle suffer from the same vulnerability and might cause problems sooner or later.
(0021167)
Brad King (manager)
2010-06-25 09:12

Please test 0001-FindMPI-Parse-mpicc-flags-more-carefully-9093.patch on top of the previously mentioned fix.
(0021176)
Brad King (manager)
2010-06-25 14:28

I've received reports of success by email for the patch. I pushed it to next:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d84cbd0f [^]

 Issue History
Date Modified Username Field Change
2009-06-02 06:07 Marcel Loose New Issue
2009-06-02 17:37 Marcel Loose Note Added: 0016608
2009-06-03 04:16 Marcel Loose File Added: FindMPI.cmake.patch
2009-06-03 04:16 Marcel Loose Note Added: 0016609
2009-07-18 02:12 Philip Lowman Status new => assigned
2009-07-18 02:12 Philip Lowman Assigned To => Douglas Gregor
2009-10-22 09:30 Marcel Loose File Added: FindMPI.cmake.patch2
2009-10-22 09:30 Marcel Loose Note Added: 0018174
2010-06-24 17:09 Alex Neundorf Assigned To Douglas Gregor => Brad King
2010-06-24 17:10 Alex Neundorf Note Added: 0021160
2010-06-24 17:10 Alex Neundorf Status assigned => closed
2010-06-24 17:10 Alex Neundorf Resolution open => fixed
2010-06-24 17:12 Brad King Note Added: 0021161
2010-06-24 17:12 Brad King Status closed => feedback
2010-06-24 17:12 Brad King Resolution fixed => reopened
2010-06-24 17:13 Brad King Status feedback => closed
2010-06-24 17:13 Brad King Resolution reopened => fixed
2010-06-25 04:13 Marcel Loose Note Added: 0021164
2010-06-25 04:13 Marcel Loose Status closed => feedback
2010-06-25 04:13 Marcel Loose Resolution fixed => reopened
2010-06-25 09:11 Brad King File Added: 0001-FindMPI-Parse-mpicc-flags-more-carefully-9093.patch
2010-06-25 09:12 Brad King Note Added: 0021167
2010-06-25 10:47 Brad King Relationship added has duplicate 0010312
2010-06-25 14:28 Brad King Note Added: 0021176
2010-06-25 14:28 Brad King Status feedback => closed
2010-06-25 14:28 Brad King Resolution reopened => fixed
2010-08-31 17:59 David Cole Target Version => CMake 2.8.3
2010-09-09 23:50 David Cole Fixed in Version => CMake 2.8.3


Copyright © 2000 - 2018 MantisBT Team