all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Markus Triska <triska@metalevel.at>
Cc: 66313-done@debbugs.gnu.org
Subject: bug#66313: Acknowledgement (29.1.50; process-mark sometimes does not yield the expected value)
Date: Sat, 07 Oct 2023 18:03:27 +0300	[thread overview]
Message-ID: <83ttr2zd8g.fsf@gnu.org> (raw)
In-Reply-To: <87jzrytt6d.fsf@metalevel.at> (message from Markus Triska on Sat,  07 Oct 2023 16:15:38 +0200)

> From: Markus Triska <triska@metalevel.at>
> Date: Sat, 07 Oct 2023 16:15:38 +0200
> 
> 
> I have reduced this to the following problem: set-process-buffer
> sometimes unexpectedly changes the position of process-mark.
> 
> For a shorter test case that exhibits the issue, please download
> process-mark.el from:
> 
>     https://www.metalevel.at/ei/process-mark/process-mark.el
> 
> Its contents are:
> 
>    (let ((p (start-process "bash" nil "bash")))
>      (set-marker (process-mark p) (point))
>      (set-process-buffer p (current-buffer))
>      (marker-position (process-mark p)))
> 
>    (message "hello there!")
> 
> Place point after the first form in the file, and evaluate the form with
> C-x C-e.
> 
> The expected result is: 165. It is obtained with Emacs 26.1 and several
> later versions.
> 
> However, with the Emacs version I used to report this problem, the
> result I get is unexpectedly: 192.
> 
> I would greatly appreciate if the previous behaviour could be restored.

I fixed this on the emacs-29 branch, but please note that your code is
quite problematic: the set-marker call associates the process-mark
marker with the current buffer, but the process's buffer is still nil.
So between the 2nd and the 3rd line of your snippet, you have a window
where the process-mark points to a buffer different from the buffer
associated with the process.  You should do this the other way around:
first set the process-buffer, and then update the process-mark
position to a position in that buffer.

So in a nutshell, your code was hitting "undefined behavior", and
expecting it to be bug-for-bug compatible with old versions of Emacs
was not really reasonable.





  reply	other threads:[~2023-10-07 15:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 20:00 bug#66313: 29.1.50; process-mark sometimes does not yield the expected value Markus Triska
     [not found] ` <handler.66313.B.169627630221147.ack@debbugs.gnu.org>
2023-10-07 14:15   ` bug#66313: Acknowledgement (29.1.50; process-mark sometimes does not yield the expected value) Markus Triska
2023-10-07 15:03     ` Eli Zaretskii [this message]
2023-10-07 15:28       ` Markus Triska
2023-10-07 15:56         ` Eli Zaretskii
2023-10-07 16:12           ` Markus Triska

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=83ttr2zd8g.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=66313-done@debbugs.gnu.org \
    --cc=triska@metalevel.at \
    /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.