From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: infinite loop in boyer_moore() Date: Thu, 16 Apr 2009 00:51:45 -0400 Message-ID: <87prfdp5em.fsf@cyd.mit.edu> References: <87eiwaheu9.fsf@cyd.mit.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1239857416 4225 80.91.229.12 (16 Apr 2009 04:50:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 16 Apr 2009 04:50:16 +0000 (UTC) Cc: 2844@emacsbugs.donarmstrong.com To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 16 06:51:35 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 1LuJZW-0004bz-E2 for ged-emacs-devel@m.gmane.org; Thu, 16 Apr 2009 06:51:34 +0200 Original-Received: from localhost ([127.0.0.1]:58413 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuJY7-0007tP-7x for ged-emacs-devel@m.gmane.org; Thu, 16 Apr 2009 00:50:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuJY1-0007tC-Rd for emacs-devel@gnu.org; Thu, 16 Apr 2009 00:50:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuJXx-0007sv-Ca for emacs-devel@gnu.org; Thu, 16 Apr 2009 00:50:01 -0400 Original-Received: from [199.232.76.173] (port=35186 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuJXx-0007ss-57 for emacs-devel@gnu.org; Thu, 16 Apr 2009 00:49:57 -0400 Original-Received: from cyd.mit.edu ([18.115.2.24]:53041) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LuJXw-0004CH-Qf for emacs-devel@gnu.org; Thu, 16 Apr 2009 00:49:56 -0400 Original-Received: by cyd.mit.edu (Postfix, from userid 1000) id 51DAD57E245; Thu, 16 Apr 2009 00:51:45 -0400 (EDT) In-Reply-To: <87eiwaheu9.fsf@cyd.mit.edu> (Chong Yidong's message of "Thu, 02 Apr 2009 18:26:38 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (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:110308 Archived-At: Ping. Anyone have an opinion? >> Gnus has been entering infinite loops for me while splitting mail. >> Today I got a chance to look into it. The problem is in >> boyer_moore(), in search.c: > >> /* Use signed comparison if appropriate >> to make cursor+infinity sure to be > p_limit. >> Assuming that the buffer lies in a range of addresses >> that are all "positive" (as ints) or all "negative", >> either kind of comparison will work as long >> as we don't step by infinity. So pick the kind >> that works when we do step by infinity. */ >> if ((EMACS_INT) (p_limit + infinity) > (EMACS_INT) p_limit) >> while ((EMACS_INT) cursor <= (EMACS_INT) p_limit) >> cursor += BM_tab[*cursor]; >> else >> while ((EMACS_UINT) cursor <= (EMACS_UINT) p_limit) >> cursor += BM_tab[*cursor]; > >> it takes the signed (EMACS_INT) loop, but that fails because cursor is >> (unsigned char *) 0x7fffc440, whereas p_limit is (unsigned char *) >> 0x80001260. > >> infinity, computed earlier in that function, is 0x37dac21, but I don't >> see how a positive value would have helped. It seems to me that we >> have to check that we won't be crossing this boundary starting at >> cursor rather than p_limit, or maybe both. I haven't thought much >> about it. > > Checking with cursor as well as p_limit sounds about right to be, but I > am far from familiar with this part of the code. Does anyone one this > list have an opinion?