Opened 19 years ago

#11 new defect

CMT v1r18p20050501 malfunctions if `.' is present in PATH

Reported by: snyder@… Owned by: arnault
Priority: normal Milestone:
Component: c. Core Version: v1r18
Severity: normal Keywords:
Cc: OS: All
If Other, could you precise: Experiment: Other
If Other, could you precise:
Stack trace:
Steps to reproduce:

Description

[This was observed in the Atlas build system as of 10.4.1.] CMT v1r18p20050501 malfunctions if `.' is present in PATH. Some path elements which are supposed to be present are missing:

$ cmt show set PATH ... PATH='/usatlas/workarea/snyder/atlas-10.4.1-dv/InstallArea/i686-slc3-gcc323-dbg/bin:/afs/usatlas.bnl.gov/software/dist/10.4.1/InstallArea/i686-slc3-gcc323-dbg/bin:/afs/usatlas.bnl.gov/offline/external/Gaudi/0.16.1.6/InstallArea/i686-slc3-gcc323-dbg/bin:/afs/usatlas.bnl.gov/cernsw/contrib/CMT/v1r18p20050501/${CMTBIN}:/usatlas/u/snyder/bin:/usr/sbin:/sbin:/etc/X11:/usr/sbin:/sbin:/etc/X11:/sbin:/bin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/bin/mh:/root/bin:/usr/X11R6/bin:/usr/bin/mh:/usr/X11R6/bin:/usr/local/bin:/usr/afsws/bin:/etc:/usr/lib:/afs/cern.ch/atlas/software/bin'

$ PATH=.:$PATH cmt show set PATH ... PATH='/afs/usatlas.bnl.gov/cernsw/contrib/CMT/v1r18p20050501/${CMTBIN}:.:/usatlas/u/snyder/bin:/usr/sbin:/sbin:/etc/X11:/usr/sbin:/sbin:/etc/X11:/sbin:/bin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/bin/mh:/root/bin:/usr/X11R6/bin:/usr/bin/mh:/usr/X11R6/bin:/usr/local/bin:/usr/afsws/bin:/etc:/usr/lib:/afs/cern.ch/atlas/software/bin'

Admittedly, having `.' in your PATH is usually a bad idea, but cmt should still not be behaving like this.

The culprit is this function:

static bool find_path_entry (const cmt_string& paths, const cmt_string& value) {

static const cmt_string path_separator = CmtSystem::path_separator ();

cmt_string here = CmtSystem::pwd (); cmt_string rvalue = value;

if (CmtSystem::cd (value))

{

rvalue = CmtSystem::pwd ();

}

else

{

CmtSystem::compress_path (rvalue);

}

CmtSystem::cmt_string_vector items; CmtSystem::split (paths, path_separator, items);

bool found = false;

for (int i = 0; i < items.size (); i++)

{

const cmt_string& item = items[i]; cmt_string ritem = item; if (CmtSystem::cd (item))

{

ritem = CmtSystem::pwd ();

}

else

{

CmtSystem::compress_path (ritem);

}

if (ritem == rvalue)

{

found = true; break;

}

}

CmtSystem::cd (here); return (found);

}

Suppose PATHS does not contain VALUE, but it starts with `.'. After the bit before the loop, cwd will be VALUE. On the first pass through the loop, ITEM will be `.'. The code does a cd to `.' followed by a pwd --- which will return VALUE again. So the ritem == rvalue test will succeed, even though VALUE isn't in PATHS.

One could also run into similar problems if PATH contains any entries which are not absolute. Probably the best fix is to cd back to HERE after each test, rather than only doing it at the end.

sss

Change History (0)

Note: See TracTickets for help on using tickets.