From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 20 00:39:52 2011 Received: (at submit) by debbugs.gnu.org; 20 Mar 2011 04:39:53 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1AQi-0001Gw-Dg for submit@debbugs.gnu.org; Sun, 20 Mar 2011 00:39:52 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1AQf-0001Gj-Cj for submit@debbugs.gnu.org; Sun, 20 Mar 2011 00:39:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1AQZ-0002NC-Dp for submit@debbugs.gnu.org; Sun, 20 Mar 2011 00:39:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:33643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1AQZ-0002N8-BM for submit@debbugs.gnu.org; Sun, 20 Mar 2011 00:39:43 -0400 Received: from [140.186.70.92] (port=37092 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1AQY-0002l5-88 for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 00:39:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1AQW-0002Mq-Mt for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 00:39:42 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:33086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1AQW-0002LY-5s for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 00:39:40 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 3EB6839E8116 for ; Sat, 19 Mar 2011 21:39:32 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aphfXJVoT+jK for ; Sat, 19 Mar 2011 21:39:31 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 46FD439E80DB for ; Sat, 19 Mar 2011 21:39:31 -0700 (PDT) Message-ID: <4D858502.8050800@cs.ucla.edu> Date: Sat, 19 Mar 2011 21:39:30 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: 'volatile' needed for local variables around vfork Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -4.6 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.6 (----) In three places, GNU Emacs assumes that a local variable is preserved after a successful vfork, but on some architectures these variables may be clobbered. (I found this problem by compiling with gcc -Wclobbered.) I plan to address this problem with the following patch: 2011-03-19 Paul Eggert * callproc.c (Fcall_process): Use 'volatile' to avoid vfork clobbering. * process.c (create_process): Likewise. * sysdep.c (sys_subshell): Likewise. Previously, the sys_subshell 'volatile' was incorrectly IF_LINTted out. === modified file 'src/callproc.c' --- src/callproc.c 2011-03-18 04:45:18 +0000 +++ src/callproc.c 2011-03-18 05:56:46 +0000 @@ -180,7 +180,7 @@ (int nargs, register Lisp_Object *args) { Lisp_Object infile, buffer, current_dir, path; - int display_p; + volatile int display_p_volatile; int fd[2]; int filefd; register int pid; @@ -190,6 +190,7 @@ int bufsize = CALLPROC_BUFFER_SIZE_MIN; int count = SPECPDL_INDEX (); + const unsigned char **volatile new_argv_volatile; register const unsigned char **new_argv; /* File to use for stderr in the child. t means use same as standard output. */ @@ -343,7 +344,7 @@ UNGCPRO; } - display_p = INTERACTIVE && nargs >= 4 && !NILP (args[3]); + display_p_volatile = INTERACTIVE && nargs >= 4 && !NILP (args[3]); filefd = emacs_open (SSDATA (infile), O_RDONLY, 0); if (filefd < 0) @@ -371,7 +372,7 @@ && SREF (path, 1) == ':') path = Fsubstring (path, make_number (2), Qnil); - new_argv = (const unsigned char **) + new_argv_volatile = new_argv = (const unsigned char **) alloca (max (2, nargs - 2) * sizeof (char *)); if (nargs > 4) { @@ -542,6 +543,8 @@ pid = vfork (); + new_argv = new_argv_volatile; + if (pid == 0) { if (fd[0] >= 0) @@ -673,6 +676,7 @@ int first = 1; EMACS_INT total_read = 0; int carryover = 0; + int display_p = display_p_volatile; int display_on_the_fly = display_p; struct coding_system saved_coding; === modified file 'src/process.c' --- src/process.c 2011-03-20 02:48:50 +0000 +++ src/process.c 2011-03-20 03:07:54 +0000 @@ -1912,8 +1912,7 @@ /* child_setup must clobber environ on systems with true vfork. Protect it from permanent change. */ char **save_environ = environ; - - current_dir = ENCODE_FILE (current_dir); + volatile Lisp_Object encoded_current_dir = ENCODE_FILE (current_dir); #ifndef WINDOWSNT pid = vfork (); @@ -2054,13 +2053,13 @@ child_setup_tty (xforkout); #ifdef WINDOWSNT pid = child_setup (xforkin, xforkout, xforkout, - new_argv, 1, current_dir); + new_argv, 1, encoded_current_dir); #else /* not WINDOWSNT */ #ifdef FD_CLOEXEC emacs_close (wait_child_setup[0]); #endif child_setup (xforkin, xforkout, xforkout, - new_argv, 1, current_dir); + new_argv, 1, encoded_current_dir); #endif /* not WINDOWSNT */ } environ = save_environ; === modified file 'src/sysdep.c' --- src/sysdep.c 2011-03-14 23:31:21 +0000 +++ src/sysdep.c 2011-03-18 05:50:40 +0000 @@ -488,7 +488,8 @@ int pid; struct save_signal saved_handlers[5]; Lisp_Object dir; - unsigned char * IF_LINT (volatile) str = 0; + unsigned char *volatile str_volatile = 0; + unsigned char *str; int len; saved_handlers[0].code = SIGINT; @@ -512,7 +513,7 @@ goto xyzzy; dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); - str = (unsigned char *) alloca (SCHARS (dir) + 2); + str_volatile = str = (unsigned char *) alloca (SCHARS (dir) + 2); len = SCHARS (dir); memcpy (str, SDATA (dir), len); if (str[len - 1] != '/') str[len++] = '/'; @@ -544,6 +545,7 @@ sh = "sh"; /* Use our buffer's default directory for the subshell. */ + str = str_volatile; if (str && chdir ((char *) str) != 0) { #ifndef DOS_NT From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 23 18:07:00 2011 Received: (at 8298-done) by debbugs.gnu.org; 23 Mar 2011 22:07:03 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2WCi-0007uv-6M for submit@debbugs.gnu.org; Wed, 23 Mar 2011 18:07:00 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2WCb-0007uA-KO; Wed, 23 Mar 2011 18:06:54 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 7955339E80F5; Wed, 23 Mar 2011 15:06:47 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DCQ03AM5OnEs; Wed, 23 Mar 2011 15:06:47 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 2047839E80B1; Wed, 23 Mar 2011 15:06:47 -0700 (PDT) Message-ID: <4D8A6EF6.6010006@cs.ucla.edu> Date: Wed, 23 Mar 2011 15:06:46 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9 MIME-Version: 1.0 To: 8310-done@debbugs.gnu.org, 8318-done@debbugs.gnu.org, 8306-done@debbugs.gnu.org, 8303-done@debbugs.gnu.org, 8277-done@debbugs.gnu.org, 8298-done@debbugs.gnu.org, 8290-done@debbugs.gnu.org, 8278-done@debbugs.gnu.org Subject: fix merged to trunk Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: 8298-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.2 (---) I committed a fix to the trunk for this, as part of a recent merge (bzr 103721). From unknown Tue Jun 17 22:00:46 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 21 Apr 2011 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator