From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Willing to debug bug #3542 (23.0.94; File access via UNC path slow again under Windows) Date: Tue, 14 Jul 2009 14:18:53 -0400 Message-ID: References: <7dbe73ed0907051401o26903ca3t9a67060f3a3417ad@mail.gmail.com> <83fxda1pef.fsf@gnu.org> <7dbe73ed0907060038w53699f77ie742996955ae8118@mail.gmail.com> <838wj11sz4.fsf@gnu.org> <83my7fz09s.fsf@gnu.org> <7dbe73ed0907081347q12dfd1a2lbbff915c49362f75@mail.gmail.com> <4A55D68D.8050407@gnu.org> <7dbe73ed0907090453s3e125b4ar142b90a268b105e2@mail.gmail.com> <7DAFC004A33C486A9E29A59689E7F02E@us.oracle.com> <4A5619F5.8010008@gnu.org> <8363e1zoak.fsf@gnu.org> <83hbxjrmue.fsf@gnu.org> <83ws6cqudb.fsf@gnu.org> <83tz1gqr33.fsf@gnu.org> <83prc4q7ef.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1247595556 1232 80.91.229.12 (14 Jul 2009 18:19:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 Jul 2009 18:19:16 +0000 (UTC) Cc: schwab@linux-m68k.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 14 20:19:08 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MQmal-0007bg-8b for ged-emacs-devel@m.gmane.org; Tue, 14 Jul 2009 20:19:04 +0200 Original-Received: from localhost ([127.0.0.1]:41964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQmaj-00055u-Sd for ged-emacs-devel@m.gmane.org; Tue, 14 Jul 2009 14:19:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQmae-00054p-EH for emacs-devel@gnu.org; Tue, 14 Jul 2009 14:18:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQmaZ-00054c-DB for emacs-devel@gnu.org; Tue, 14 Jul 2009 14:18:55 -0400 Original-Received: from [199.232.76.173] (port=48763 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQmaZ-00054Z-7K for emacs-devel@gnu.org; Tue, 14 Jul 2009 14:18:51 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:36074 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MQmaT-0000VV-MJ; Tue, 14 Jul 2009 14:18:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au4EAC9pXEpMCpbp/2dsb2JhbACBUdB/hAgFhm4 X-IronPort-AV: E=Sophos;i="4.42,398,1243828800"; d="scan'208";a="41577211" Original-Received: from 76-10-150-233.dsl.teksavvy.com (HELO pastel.home) ([76.10.150.233]) by ironport2-out.teksavvy.com with ESMTP; 14 Jul 2009 14:18:38 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 146187EF7; Tue, 14 Jul 2009 14:18:53 -0400 (EDT) In-Reply-To: <83prc4q7ef.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 14 Jul 2009 06:18:32 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:112456 Archived-At: >> > From fileio.c: >> > nm = (unsigned char *) alloca (SBYTES (filename) + 1); >> > bcopy (SDATA (filename), nm, SBYTES (filename) + 1); >> > (why +1? it potentially accesses memory beyond end of `filename's >> > contents) >> The +1 is precisely used to make sure we copy the terminating NUL. > That's not my reading of allocate_string_data. Are you sure? I'm not sure about any piece of code, no. Bugs are common. But my reading of allocate_string_data starts by: /* Set up Lisp_String S for holding NCHARS characters, NBYTES bytes, plus a NUL byte at the end. Allocate an sdata structure for S, and > Anyway, if that's true, then again we have bugs in other places. Like > this one: > directory_nbytes = SBYTES (directory); > if (directory_nbytes == 0 > || !IS_ANY_SEP (SREF (directory, directory_nbytes - 1))) > needsep = 1; > [...] > int nbytes = len + directory_nbytes + needsep; > fullname = make_uninit_multibyte_string (nbytes, nbytes); > bcopy (SDATA (directory), SDATA (fullname), > directory_nbytes); make_uninit_multibyte_string calls allocate_string_data which does STRING_DATA (s)[nbytes] = '\0'; so the destination of the `bcopy' already has the terminating NUL. So, I'm overall pretty sure our strings *should* always have a NUL right after the last byte. OTOH I'd be surprised if there isn't a bug somewhere that makes it possible for some strings to occasionally fail to have this terminating NUL (most likely, any bug that leads to a crash could also lead to such a situation). Stefan