From owner-freebsd-bugs@FreeBSD.ORG Fri Dec 23 16:10:11 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 235571065687 for ; Fri, 23 Dec 2011 16:10:11 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D458F8FC14 for ; Fri, 23 Dec 2011 16:10:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pBNGAAqu005568 for ; Fri, 23 Dec 2011 16:10:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pBNGAA8w005567; Fri, 23 Dec 2011 16:10:10 GMT (envelope-from gnats) Resent-Date: Fri, 23 Dec 2011 16:10:10 GMT Resent-Message-Id: <201112231610.pBNGAA8w005567@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Tim Čas" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 672471065675 for ; Fri, 23 Dec 2011 16:09:24 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 558C68FC0C for ; Fri, 23 Dec 2011 16:09:24 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pBNG9OrL015950 for ; Fri, 23 Dec 2011 16:09:24 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id pBNG9OPd015949; Fri, 23 Dec 2011 16:09:24 GMT (envelope-from nobody) Message-Id: <201112231609.pBNG9OPd015949@red.freebsd.org> Date: Fri, 23 Dec 2011 16:09:24 GMT From: "Tim Čas" To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/163567: Make forgets to chdir back to the original directory after finding an object dir X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2011 16:10:11 -0000 >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@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: