Commit 75ec1b19 authored by Mattias Engdegård's avatar Mattias Engdegård

Fix spurious regexp reentrancy error

* src/search.c (compile_pattern): Don't give up if the last regexp
cache entry is busy.  Instead, use the last (least recently used)
non-busy entry, and only signal a reentrancy error if there is no free
entry at all (Bug#34910).
parent 9c0fa117
...@@ -198,11 +198,13 @@ static struct regexp_cache * ...@@ -198,11 +198,13 @@ static struct regexp_cache *
compile_pattern (Lisp_Object pattern, struct re_registers *regp, compile_pattern (Lisp_Object pattern, struct re_registers *regp,
Lisp_Object translate, bool posix, bool multibyte) Lisp_Object translate, bool posix, bool multibyte)
{ {
struct regexp_cache *cp, **cpp; struct regexp_cache *cp, **cpp, **lru_nonbusy;
for (cpp = &searchbuf_head; ; cpp = &cp->next) for (cpp = &searchbuf_head, lru_nonbusy = NULL; ; cpp = &cp->next)
{ {
cp = *cpp; cp = *cpp;
if (!cp->busy)
lru_nonbusy = cpp;
/* Entries are initialized to nil, and may be set to nil by /* Entries are initialized to nil, and may be set to nil by
compile_pattern_1 if the pattern isn't valid. Don't apply compile_pattern_1 if the pattern isn't valid. Don't apply
string accessors in those cases. However, compile_pattern_1 string accessors in those cases. However, compile_pattern_1
...@@ -222,13 +224,14 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp, ...@@ -222,13 +224,14 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp,
&& cp->buf.charset_unibyte == charset_unibyte) && cp->buf.charset_unibyte == charset_unibyte)
break; break;
/* If we're at the end of the cache, compile into the nil cell /* If we're at the end of the cache, compile into the last
we found, or the last (least recently used) cell with a (least recently used) non-busy cell in the cache. */
string value. */
if (cp->next == 0) if (cp->next == 0)
{ {
if (cp->busy) if (!lru_nonbusy)
error ("Too much matching reentrancy"); error ("Too much matching reentrancy");
cpp = lru_nonbusy;
cp = *cpp;
compile_it: compile_it:
eassert (!cp->busy); eassert (!cp->busy);
compile_pattern_1 (cp, pattern, translate, posix); compile_pattern_1 (cp, pattern, translate, posix);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment