unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Alan Mackenzie <acm@muc.de>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	49944@debbugs.gnu.org
Subject: bug#49944: parse-partial-sexp fails to signal an error when (> START LIMIT).
Date: Sat, 21 Aug 2021 23:11:55 +0100	[thread overview]
Message-ID: <87sfz2o3bo.fsf@tcd.ie> (raw)
In-Reply-To: <87o89r2anv.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 21 Aug 2021 15:24:20 +0200")

[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]

Lars Ingebrigtsen [2021-08-21 15:24 +0200] wrote:

> Alan Mackenzie <acm@muc.de> writes:
>
>> Emacs-28, emacs started with site-start.el and .emacs.
>>
>> On calling
>>
>>     (parse-partial-sexp 19 18 nil nil s)
>>
>> Emacs surely ought to signal an error, since 18 < 19.  It doesn't,
>> though.  It leaves point at a random position and returns
>>
>>     (0 nil nil nil nil nil 0 nil nil nil nil)
>>
>> This is a bug.
>
> I've now made this change (and the doc string clarification discussed).
> There are no test failures after the change, and I'm not getting any
> errors when running it normally, either.

Found one :).

0. emacs -Q
1. M-x toggle-debug-on-error RET
2. M-x ielm RET RET

Debugger entered--Lisp error:
    (error "End position should be larger than start position.")
  parse-partial-sexp(#<marker at 64 in *ielm*> 64)
  ielm-return()
  funcall-interactively(ielm-return)
  call-interactively(ielm-return nil nil)
  command-execute(ielm-return)

One option is to replace XFIXNUM with fix_position, which is what the
subsequent validate_region also does.  Another option is to
CHECK_FIXNUM_COERCE_MARKER before the comparison.  Any preference?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-recent-parse-partial-sexp-argument-validation.patch --]
[-- Type: text/x-diff, Size: 1069 bytes --]

From 34c87c83fa86263da863da6c0a920c746b8af02b Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sat, 21 Aug 2021 22:55:58 +0100
Subject: [PATCH] Fix recent parse-partial-sexp argument validation

* src/syntax.c (parse-partial-sexp): Also handle markers as
arguments (bug#49944).  Tweak error message to follow conventions in
"(elisp) Signaling Errors".
---
 src/syntax.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/syntax.c b/src/syntax.c
index adc0da730e..057a4c3b1f 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -3595,8 +3595,8 @@ DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0,
   else
     target = TYPE_MINIMUM (EMACS_INT);	/* We won't reach this depth.  */
 
-  if (XFIXNUM (to) < XFIXNUM (from))
-    error ("End position should be larger than start position.");
+  if (fix_position (to) < fix_position (from))
+    error ("End position is smaller than start position");
 
   validate_region (&from, &to);
   internalize_parse_state (oldstate, &state);
-- 
2.32.0


[-- Attachment #3: Type: text/plain, Size: 20 bytes --]


Thanks,

-- 
Basil

  parent reply	other threads:[~2021-08-21 22:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-08 18:01 bug#49944: parse-partial-sexp fails to signal an error when (> START LIMIT) Alan Mackenzie
2021-08-08 18:14 ` Lars Ingebrigtsen
2021-08-08 18:51   ` Alan Mackenzie
2021-08-09 12:42     ` Lars Ingebrigtsen
2021-08-09 16:50       ` Alan Mackenzie
2021-08-10 13:50         ` Lars Ingebrigtsen
2021-08-10 14:03           ` Eli Zaretskii
2021-08-10 14:41             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-10 14:54               ` Lars Ingebrigtsen
2021-08-10 15:07                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-10 15:36                 ` Eli Zaretskii
2021-08-10 15:44                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-10 16:38                     ` Eli Zaretskii
2021-08-11 11:04                       ` Lars Ingebrigtsen
2021-08-21 13:24 ` Lars Ingebrigtsen
2021-08-21 14:05   ` Alan Mackenzie
2021-08-21 22:11   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-08-22 10:50     ` Alan Mackenzie
2021-08-22 15:02     ` Lars Ingebrigtsen
2021-08-22 22:54       ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87sfz2o3bo.fsf@tcd.ie \
    --to=bug-gnu-emacs@gnu.org \
    --cc=49944@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=contovob@tcd.ie \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /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 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).