MantisBT - CMake
View Issue Details
0009093CMakeModulespublic2009-06-02 06:072010-09-09 23:50
Marcel Loose 
Brad King 
normalminorsometimes
closedfixed 
CMake-2-6 
CMake 2.8.3CMake 2.8.3 
0009093: FindMPI sometimes fails because it checks for non-existing libraries
FindMPI 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.
No tags attached.
has duplicate 0010312closed Brad King FindMPI.cmake fails for path name containing "-l" 
patch FindMPI.cmake.patch (3,481) 2009-06-03 04:16
https://public.kitware.com/Bug/file/2295/FindMPI.cmake.patch
? FindMPI.cmake.patch2 (3,750) 2009-10-22 09:30
https://public.kitware.com/Bug/file/2587/FindMPI.cmake.patch2
patch 0001-FindMPI-Parse-mpicc-flags-more-carefully-9093.patch (2,836) 2010-06-25 09:11
https://public.kitware.com/Bug/file/3209/0001-FindMPI-Parse-mpicc-flags-more-carefully-9093.patch
Issue History
2009-06-02 06:07Marcel LooseNew Issue
2009-06-02 17:37Marcel LooseNote Added: 0016608
2009-06-03 04:16Marcel LooseFile Added: FindMPI.cmake.patch
2009-06-03 04:16Marcel LooseNote Added: 0016609
2009-07-18 02:12Philip LowmanStatusnew => assigned
2009-07-18 02:12Philip LowmanAssigned To => Douglas Gregor
2009-10-22 09:30Marcel LooseFile Added: FindMPI.cmake.patch2
2009-10-22 09:30Marcel LooseNote Added: 0018174
2010-06-24 17:09Alex NeundorfAssigned ToDouglas Gregor => Brad King
2010-06-24 17:10Alex NeundorfNote Added: 0021160
2010-06-24 17:10Alex NeundorfStatusassigned => closed
2010-06-24 17:10Alex NeundorfResolutionopen => fixed
2010-06-24 17:12Brad KingNote Added: 0021161
2010-06-24 17:12Brad KingStatusclosed => feedback
2010-06-24 17:12Brad KingResolutionfixed => reopened
2010-06-24 17:13Brad KingStatusfeedback => closed
2010-06-24 17:13Brad KingResolutionreopened => fixed
2010-06-25 04:13Marcel LooseNote Added: 0021164
2010-06-25 04:13Marcel LooseStatusclosed => feedback
2010-06-25 04:13Marcel LooseResolutionfixed => reopened
2010-06-25 09:11Brad KingFile Added: 0001-FindMPI-Parse-mpicc-flags-more-carefully-9093.patch
2010-06-25 09:12Brad KingNote Added: 0021167
2010-06-25 10:47Brad KingRelationship addedhas duplicate 0010312
2010-06-25 14:28Brad KingNote Added: 0021176
2010-06-25 14:28Brad KingStatusfeedback => closed
2010-06-25 14:28Brad KingResolutionreopened => fixed
2010-08-31 17:59David ColeTarget Version => CMake 2.8.3
2010-09-09 23:50David ColeFixed in Version => CMake 2.8.3

Notes
(0016608)
Marcel Loose   
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   
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   
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   
2010-06-24 17:10   
If I see it correctly Brad committed a fix for this today to branch next.

Alex
(0021161)
Brad King   
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   
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   
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   
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 [^]