1
1

Discovered a very, very interesting bug, courtesy of Jeff point out some unexpected behavior under Linux. It turns out that the Linux "dirname" function has a bug in it - namely, it modifies the argument passed to it, in violation of its documentation. This was apparently fixed in the Mac library - it definitely does NOT modify its argument on the Mac.

After spending hours tracking this down, I finally did manage to isolate it to the dirname function. I have installed a "fix" for the problem (using an intermediate temporary copy of the string being passed to the function) that solves the problem without messing us up on the Mac.

Hopefully, we won't find too many more such "cute" errors!

This commit was SVN r2643.
Этот коммит содержится в:
Ralph Castain 2004-09-14 03:59:17 +00:00
родитель 164293313b
Коммит f3256a1140
2 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -16,7 +16,7 @@
int ompi_os_create_dirpath(const char *path, const mode_t mode)
{
char *pth, *bottom_up;
char *pth, *bottom_up, *tmp;
struct stat buf;
if (NULL == path) { /* protect ourselves from errors */
@ -58,7 +58,9 @@ int ompi_os_create_dirpath(const char *path, const mode_t mode)
while (strcmp(pth, ".") != 0 && stat(pth, &buf) != 0) { /* see if directory exists, or if we've reached the top */
strcat(bottom_up, basename(pth)); /* doesn't exist yet, so save this name */
strcat(bottom_up, ompi_system_info.path_sep);
strcpy(pth, dirname(pth)); /* "pop" the directory tree */
tmp = strdup(pth);
strcpy(pth, dirname(tmp)); /* "pop" the directory tree */
free(tmp);
}
/* okay, ready to build from the top down */

Просмотреть файл

@ -77,7 +77,7 @@ int ompi_session_dir(bool create, char *prfx, char *usr, char *hostid,
{
char *fulldirpath=NULL, *tmp=NULL, *hostname=NULL, *batchname=NULL;
char *sessions=NULL, *frontend=NULL, *user=NULL, *universe=NULL;
char *prefix=NULL;
char *prefix=NULL, *sav=NULL;
int return_code;
/* ensure that system info is set */
@ -222,14 +222,18 @@ int ompi_session_dir(bool create, char *prfx, char *usr, char *hostid,
if (NULL == ompi_process_info.proc_session_dir && NULL != proc) {
ompi_process_info.proc_session_dir = strdup(fulldirpath);
sav = strdup(fulldirpath);
free(fulldirpath);
fulldirpath = strdup(dirname(ompi_process_info.proc_session_dir));
fulldirpath = strdup(dirname(sav));
free(sav);
}
if (NULL == ompi_process_info.job_session_dir && NULL != job) {
ompi_process_info.job_session_dir = strdup(fulldirpath);
sav = strdup(fulldirpath);
free(fulldirpath);
fulldirpath = strdup(dirname(ompi_process_info.job_session_dir));
fulldirpath = strdup(dirname(sav));
free(sav);
}
if (NULL == ompi_process_info.universe_session_dir) {