all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: emacs-devel@gnu.org
Subject: (error "Stack overflow in regexp matcher") and (?)wrong display of regexp in backtrace
Date: Sun, 15 Mar 2020 10:39:22 +0000	[thread overview]
Message-ID: <20200315103922.GA4928@ACM> (raw)

Hello, Emacs.

I'm not sure whether I've tripped over bugs or not here, so I'm posting
to emacs-devel.

1. Start the Emacs-27 pretest or master with -Q.
2. Visit the file given for bug #40052, namely:

    http://hg.openjdk.java.net/jdk/jdk/raw-file/29edf1cb3c02/src/hotspot/share/runtime/globals.hpp

.  (Note: this file is one gigantic #define macro and is thus slow to
scroll, etc.  That is the topic of bug #40052.)
3. M-: (setq debug-on-error t)
4. move point to the #define at line 115.
5. Type a space.

This causes a stack overflow error in the regexp engine, producing this
backtrace:

Debugger entered--Lisp error: (error "Stack overflow in regexp matcher")
  re-search-forward("\\(\\\\\\(.\\|\n\\)\\|[^\\\n\15]\\)*" nil t)
  c-before-change-check-unbalanced-strings(5717 5717)
  #f(compiled-function (fn) #<bytecode 0x158b20edb5bd>)(c-before-change-check-unbalanced-strings)
  mapc(#f(compiled-function (fn) #<bytecode 0x158b20edb5bd>) (c-extend-region-for-CPP c-before-change-check-raw-strings c-before-change-check-<>-operators c-depropertize-CPP c-invalidate-macro-cache c-truncate-bs-cache c-before-change-chec$
  c-before-change(5717 5717)
  self-insert-command(1 32)
  funcall-interactively(self-insert-command 1 32)
  call-interactively(self-insert-command nil nil)
  command-execute(self-insert-command)

First of all, note the regexp, "\\(\\\\\\(.\\|\n\\)\\|[^\\\n\15]\\)*"
                                                            ^^^
In the source, the "\15" is "\r".  Why is this substitution being made
for the backtrace?  Is it intentional (in which case, why not do the
same to the "\n"?), or is it a bug?  To me, it is more like a bug.

More importantly, why is there a stack overflow here at all?  Even
though the regexp matcher has a long, long piece of buffer to scan over,
the regexp is a simple linear search, without any nesting to speak of.
There would appear to be no need for any backtracking.

-- 
Alan Mackenzie (Nuremberg, Germany).



             reply	other threads:[~2020-03-15 10:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-15 10:39 Alan Mackenzie [this message]
2020-03-15 12:22 ` (error "Stack overflow in regexp matcher") and (?)wrong display of regexp in backtrace Mattias Engdegård
2020-03-15 12:33   ` Mattias Engdegård
2020-03-15 16:57   ` Alan Mackenzie
2020-03-15 20:06     ` Mattias Engdegård
2020-03-15 14:21 ` Noam Postavsky
2020-03-15 14:56   ` Eli Zaretskii
2020-03-15 16:35 ` Stefan Monnier
2020-03-15 17:32   ` Alan Mackenzie
2020-03-15 17:38     ` Mattias Engdegård
2020-03-15 17:46       ` Eli Zaretskii
2020-03-15 18:02         ` Andreas Schwab
2020-03-16  0:32           ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200315103922.GA4928@ACM \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.