bin/163567: Make forgets to chdir back to the original directory after finding an object dir

Tim Čas darkuranium at gmail.com
Fri Dec 23 16:10:11 UTC 2011


>Number:         163567
>Category:       bin
>Synopsis:       Make forgets to chdir back to the original directory after finding an object dir
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 23 16:10:10 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Tim Čas
>Release:        9.0 RC3
>Organization:
n/a
>Environment:
FreeBSD tsibsd.tsi 9.0-RC3 FreeBSD 9.0-RC3 #0: Sun Dec  4 08:56:36 UTC 2011     root at farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
If the "make" utility finds an object dir, it changes to the path of the dir, but forgets to change back to the working directory.

A consequence of this is that portable makefiles do not work with BSD's implementation simply because there exists an "obj" directory in the tree.

This means that, say, trying to compile src/main.c actually invokes the compiler on (non-existing) obj/src/main.c.
>How-To-Repeat:
Run the following in a shell ('$' indicates a prompt):

$ rm -rf obj
$ echo -e "all:\n\tpwd" > Makefile
$ make
pwd
/path/to/dir
$ mkdir obj
$ make
pwd
/path/to/dir/obj

The effect is the same if "pwd" is replaced with \$\$PWD (which generates "$$PWD" instead of "pwd" in the makefile.
>Fix:
The problem is that chdir_verify_path does not change the directory back on success.

In the file /usr/src/usr.bin/make/main.c, change the function chdir_verify_path() - right before "return (obpath)", add:

chdir(curdir);

(plus checks to see if this went fine).


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list