From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Questionable code in handling of wordend in the regexp engine in regex-emacs.c Date: Fri, 1 Mar 2019 19:16:07 +0000 Message-ID: <20190301191607.GG5674@ACM> References: <20190225185656.GA3605@ACM> <20190301111018.GA5674@ACM> <83bm2uiu6x.fsf@gnu.org> <20190301141448.GC5674@ACM> <834l8mirj9.fsf@gnu.org> <20190301145856.GE5674@ACM> <83zhqeh8ds.fsf@gnu.org> <20190301163824.GF5674@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="233081"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 01 20:28:05 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gznpF-000yWP-0o for ged-emacs-devel@m.gmane.org; Fri, 01 Mar 2019 20:28:05 +0100 Original-Received: from localhost ([127.0.0.1]:42913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gznpE-00038P-0Z for ged-emacs-devel@m.gmane.org; Fri, 01 Mar 2019 14:28:04 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gznin-0006ez-N2 for emacs-devel@gnu.org; Fri, 01 Mar 2019 14:21:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gznil-0005VU-Bi for emacs-devel@gnu.org; Fri, 01 Mar 2019 14:21:25 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:39023 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1gznih-0005NY-TD for emacs-devel@gnu.org; Fri, 01 Mar 2019 14:21:21 -0500 Original-Received: (qmail 82985 invoked by uid 3782); 1 Mar 2019 19:21:10 -0000 Original-Received: from acm.muc.de (p4FE15D75.dip0.t-ipconnect.de [79.225.93.117]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 01 Mar 2019 20:21:09 +0100 Original-Received: (qmail 3892 invoked by uid 1000); 1 Mar 2019 19:16:07 -0000 Content-Disposition: inline In-Reply-To: <20190301163824.GF5674@ACM> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.1 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:233745 Archived-At: Hello again, Eli. On Fri, Mar 01, 2019 at 16:38:25 +0000, Alan Mackenzie wrote: > On Fri, Mar 01, 2019 at 18:22:39 +0200, Eli Zaretskii wrote: > > > Date: Fri, 1 Mar 2019 14:58:56 +0000 > > > Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org > > > From: Alan Mackenzie [ .... ] > > Actually, what I had in mind was a simple > > eassert (CHAR_HEAD_P (BUF_FETCH_BYTE (b, bytepos))); > > right at the beginning of buf_bytepos_to_charpos. [ .... ] I'm experimenting with: diff --git a/src/marker.c b/src/marker.c index b58051a8c2..89b6ca57f4 100644 --- a/src/marker.c +++ b/src/marker.c @@ -322,6 +322,9 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) ptrdiff_t distance = BYTECHAR_DISTANCE_INITIAL; eassert (BUF_BEG_BYTE (b) <= bytepos && bytepos <= BUF_Z_BYTE (b)); + /* Check bytepos is not in the middle of a character. */ + eassert (bytepos >= BUF_Z_BYTE (b) + || CHAR_HEAD_P (BUF_FETCH_BYTE (b, bytepos))); best_above = BUF_Z (b); best_above_byte = BUF_Z_BYTE (b); After configuring with --enable-checking and building, I tried make check. The tests errored out with this bytepos check three times. In: src/coding-tests.log lisp/epg-tests.log lisp/emacs-lisp/package-tests.log . Quite possibly there is just one bug here, but there might be two or three. I think it would be best to track it/them down before committing the change to marker.c. -- Alan Mackenzie (Nuremberg, Germany).