From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 0c94b84: * nt/inc/ms-w32.h (execve) [MINGW_W64]: Make commentary more accurate. Date: Fri, 02 Sep 2016 09:53:18 +0300 Message-ID: <83vayeeqsh.fsf@gnu.org> References: <20160901171604.9042.16589@vcs.savannah.gnu.org> <20160901171604.8DF4D22016A@vcs.savannah.gnu.org> <518bc279-ee83-356a-51af-fd348d32aa4f@cornell.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1472799311 6130 195.159.176.226 (2 Sep 2016 06:55:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 2 Sep 2016 06:55:11 +0000 (UTC) Cc: angelo.graziosi@alice.it, emacs-devel@gnu.org To: Ken Brown , Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 02 08:55:07 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfiNW-0000zu-D2 for ged-emacs-devel@m.gmane.org; Fri, 02 Sep 2016 08:55:06 +0200 Original-Received: from localhost ([::1]:40574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfiNU-0006fY-31 for ged-emacs-devel@m.gmane.org; Fri, 02 Sep 2016 02:55:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfiNM-0006fF-38 for emacs-devel@gnu.org; Fri, 02 Sep 2016 02:54:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfiNG-0006lB-Bz for emacs-devel@gnu.org; Fri, 02 Sep 2016 02:54:55 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:49031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfiLm-0006VS-1P; Fri, 02 Sep 2016 02:53:18 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2022 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bfiLj-0006QZ-IV; Fri, 02 Sep 2016 02:53:16 -0400 In-reply-to: <518bc279-ee83-356a-51af-fd348d32aa4f@cornell.edu> (message from Ken Brown on Thu, 1 Sep 2016 15:57:00 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207113 Archived-At: > From: Ken Brown > Cc: Angelo Graziosi > Date: Thu, 1 Sep 2016 15:57:00 -0400 > > On 9/1/2016 1:16 PM, Eli Zaretskii wrote: > > + However, using the prototype with intptr_t causes GCC to emit > > + warnings. Fortunately, execve is not used in the MinGW build, but > > + the code that references it is still compiled. */ > > Wouldn't it be easier to prevent that code from being compiled? It would for the Windows build, but it would add one (actually more, see below) #ifdef WINDOWSNT into the mainline code. AFAIR, Paul (CC'ed) wanted to keep those to a minimum, so I preferred not to ifdef away the code. > I think the following would suffice: > > --- a/src/sysdep.c > +++ b/src/sysdep.c > @@ -146,6 +146,7 @@ disable_address_randomization (void) > } > #endif > > +#ifndef WINDOWSNT > /* Execute the program in FILE, with argument vector ARGV and environ > ENVP. Return an error number if unsuccessful. This is like execve > except it reenables ASLR in the executed program if necessary, and > @@ -170,6 +171,7 @@ emacs_exec_file (char const *file, char *const > *argv, char *const *envp) > > return err; > } > +#endif /* not WINDOWSNT */ That whole function is not used on Windows, so if we are to do this, the following fragment of main in emacs.c should also be ifdefed away: /* True if address randomization interferes with memory allocation. */ # ifdef __PPC64__ bool disable_aslr = true; # else bool disable_aslr = dumping; # endif if (disable_aslr && disable_address_randomization ()) { /* Set this so the personality will be reverted before execs after this one. */ xputenv ("EMACS_HEAP_EXEC=true"); /* Address randomization was enabled, but is now disabled. Re-execute Emacs to get a clean slate. */ execvp (argv[0], argv); /* If the exec fails, warn and then try anyway. */ perror (argv[0]); } If Paul doesn't mind (nor anyone else), we can certainly do that. Thanks.