unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: infinite loop in boyer_moore()
@ 2009-04-02 22:26 Chong Yidong
  2009-04-16  4:51 ` Chong Yidong
  0 siblings, 1 reply; 4+ messages in thread
From: Chong Yidong @ 2009-04-02 22:26 UTC (permalink / raw)
  To: emacs-devel; +Cc: 2844

> 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?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: infinite loop in boyer_moore()
  2009-04-02 22:26 infinite loop in boyer_moore() Chong Yidong
@ 2009-04-16  4:51 ` Chong Yidong
  2009-04-16  9:32   ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Chong Yidong @ 2009-04-16  4:51 UTC (permalink / raw)
  To: emacs-devel; +Cc: 2844

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?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: infinite loop in boyer_moore()
  2009-04-16  4:51 ` Chong Yidong
@ 2009-04-16  9:32   ` Andreas Schwab
  2009-04-16 13:42     ` Chong Yidong
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2009-04-16  9:32 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 2844, emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

> Ping.  Anyone have an opinion?

I've now checked in a fix.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: infinite loop in boyer_moore()
  2009-04-16  9:32   ` Andreas Schwab
@ 2009-04-16 13:42     ` Chong Yidong
  0 siblings, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2009-04-16 13:42 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 2844-done, emacs-devel

Andreas Schwab <schwab@linux-m68k.org> writes:

>> Ping.  Anyone have an opinion?
>
> I've now checked in a fix.
>
> Andreas.

Thanks.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-16 13:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-02 22:26 infinite loop in boyer_moore() Chong Yidong
2009-04-16  4:51 ` Chong Yidong
2009-04-16  9:32   ` Andreas Schwab
2009-04-16 13:42     ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).