unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@protonmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Eli Zaretskii <eliz@gnu.org>,
	acorallo@gnu.org, emacs-devel@gnu.org, stefankangas@gmail.com
Subject: Re: master 8c81818673a 6/7: Tune volatile in read_char
Date: Mon, 19 Aug 2024 23:40:18 +0000	[thread overview]
Message-ID: <87jzgcaxpe.fsf@protonmail.com> (raw)
In-Reply-To: <bac3f0f6-9461-414c-ada6-6337fe7c1477@cs.ucla.edu>

"Paul Eggert" <eggert@cs.ucla.edu> writes:

> On 2024-08-19 13:08, Pip Cet wrote:
>> one can come up with similar examples without a
>> backward jump, which loop unquittably even in emacs-30
>
> Ouch, in that case this issue happens regardless of the recent
> 'volatile'-related changes, and we should address the issue regardless
> of what we do with 'volatile'.

Agreed.

> Would the attached patch fix the issue in master? It can be tuned
> further (and obviously needs comments); I'm just trying to see whether I
> understand the point you're making.

 		pc = bytestr_data;
 		PUSH (c->val);
+		if (BYTE_CODE_SAFE)
+		  quitcounter += ! (op < 0);
 		goto op_branch;
 	      }

Yes, that does work, though I had to fix a bug in my code and it now
reads:

(disassemble #[65535 "\210\3011\0\0\202\013\0\302\211\241\202\010\000"
[argument (wrong-type-argument) 0 t] 65536])

But, as you say, it could be simplified:

 		pc = bytestr_data;
 		PUSH (c->val);
+		if (BYTE_CODE_SAFE)
+		  quitcounter++;
 		goto op_branch;
 	      }

'op' is relative to the beginning of the byte string, so it should never
be less than 0.  If it is, and BYTE_CODE_SAFE is true, we will call
emacs_abort in op_branch.

> This patch affects behavior only if BYTE_CODE_SAFE, because as I
> understand things we trust bytecode anyway otherwise.

(That reminds me of a bug that I hunted down in which it turned out gcc
helpfully generated different code depending on whether -g (not -Og) was
specified or not.  I would prefer to err on the side of making things
reproducible and unconditionally increment quitcounter.)

By the way, I was very surprised that 'signal_or_quit', by way of
'Fmemq', calls 'maybe_quit'.  I hope that cannot result in infinite
recursion.

Pip




      reply	other threads:[~2024-08-19 23:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <172386820621.30556.15409337288904485218@vcs2.savannah.gnu.org>
     [not found] ` <20240817041648.A6687C2BC66@vcs2.savannah.gnu.org>
2024-08-17 15:04   ` master 8c81818673a 6/7: Tune volatile in read_char Andrea Corallo
2024-08-17 17:03     ` Pip Cet
2024-08-17 18:16       ` Paul Eggert
2024-08-17 18:17     ` Paul Eggert
2024-08-18  7:39       ` Andrea Corallo
2024-08-18 21:39         ` Paul Eggert
2024-08-18 21:57           ` Sam James
2024-08-18 22:03             ` Paul Eggert
2024-08-19 14:43           ` Andrea Corallo
2024-08-19 15:01             ` Eli Zaretskii
2024-08-19 15:32               ` Pip Cet
2024-08-19 15:44                 ` Eli Zaretskii
2024-08-19 16:01                   ` Pip Cet
2024-08-19 16:15                     ` Eli Zaretskii
2024-08-19 18:59                       ` Paul Eggert
2024-08-19 19:27                         ` Eli Zaretskii
2024-08-19 19:05                       ` Pip Cet
2024-08-19 19:29                         ` Eli Zaretskii
2024-08-19 19:43                           ` Paul Eggert
2024-08-19 20:08                             ` Pip Cet
2024-08-19 22:20                               ` Paul Eggert
2024-08-19 23:40                                 ` Pip Cet [this message]

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=87jzgcaxpe.fsf@protonmail.com \
    --to=pipcet@protonmail.com \
    --cc=acorallo@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=stefankangas@gmail.com \
    /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).