From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Angelo Graziosi Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 0c94b84: * nt/inc/ms-w32.h (execve) [MINGW_W64]: Make commentary more accurate. Date: Sun, 4 Sep 2016 12:34:20 +0200 Message-ID: <7f482669-53eb-a22d-54bf-a781a36b46de@alice.it> References: <20160901171604.9042.16589@vcs.savannah.gnu.org> <20160901171604.8DF4D22016A@vcs.savannah.gnu.org> <518bc279-ee83-356a-51af-fd348d32aa4f@cornell.edu> <83vayeeqsh.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1472985616 4609 195.159.176.226 (4 Sep 2016 10:40:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Sep 2016 10:40:16 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 Cc: emacs-devel@gnu.org To: Eli Zaretskii , Ken Brown , Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 04 12:40:12 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 1bgUqO-0000KA-5L for ged-emacs-devel@m.gmane.org; Sun, 04 Sep 2016 12:40:08 +0200 Original-Received: from localhost ([::1]:49365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgUqL-0007Ls-TG for ged-emacs-devel@m.gmane.org; Sun, 04 Sep 2016 06:40:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgUqF-0007Lh-FB for emacs-devel@gnu.org; Sun, 04 Sep 2016 06:40:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgUqB-0005Nl-7w for emacs-devel@gnu.org; Sun, 04 Sep 2016 06:39:58 -0400 Original-Received: from smtp203.alice.it ([82.57.200.99]:5433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgUqA-0005Ng-S0; Sun, 04 Sep 2016 06:39:55 -0400 Original-Received: from [192.168.1.100] (79.45.0.244) by smtp203.alice.it (8.6.060.43) (authenticated as angelo.graziosi@alice.it) id 57AB225A0369FF5E; Sun, 4 Sep 2016 12:34:33 +0200 In-Reply-To: <83vayeeqsh.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.99 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:207167 Archived-At: Hi Paul, Il 02/09/2016 08:53, Eli Zaretskii ha scritto: >> 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. if I understand (in short) there is code compiled but not used.. Would it better to exclude that code as Ken suggests, then? May you comment? Thanks, Angelo. > >> 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. >