unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Gong Qijian <gongqijian@gmail.com>
To: 74274@debbugs.gnu.org
Cc: "Gerd Möllmann" <gerd@gnu.org>, "Gong Qijian" <gongqijian@gmail.com>
Subject: bug#74274: [PATCH] Revert part of d3f8ed730f to avoid segmentation fault
Date: Fri,  8 Nov 2024 14:31:50 +0800	[thread overview]
Message-ID: <20241108063148.30423-3-gongqijian@gmail.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1930 bytes --]

Patch for branch scratch/tty-child-frames to avoid segmentation fault.

The issue can be triggered by the message function when creating a tty
child frame during the initialization process.

Reproduce:

  $ src/emacs -nw -Q --eval "\
    (progn
      (require 'cl-lib)
      (require 'tty-tip)
      (advice-add 'tty-tip--compute-position :around
       (defun tty-tip--compute-position@fix-nil-error (&rest args)
         (cl-letf ((orig-mouse-position (symbol-function #'mouse-position))
                   ((symbol-function #'mouse-position)
                    (lambda ()
                      (if (terminal-parameter nil 'xterm-mouse-x)
                          (funcall orig-mouse-position)
                        (cons (window-frame) (posn-x-y (posn-at-point)))))))
           (apply args))))

      (tty-tip--create-frame \"line1\nline2\")
      (message \"tty-type: %S\" (tty-type)))"
  Fatal error 11: Segmentation fault
  ^[[Ifish: Job 1, 'src/emacs -nw -Q --eval "\…' terminated by signal (pro… (SIGABRT)
  fish: Job Abort, '' terminated by signal  ()

---
 src/term.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/term.c b/src/term.c
index a7f7baa6e3..8aeabd76b7 100644
--- a/src/term.c
+++ b/src/term.c
@@ -781,7 +781,11 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
     {
       /* Identify a run of glyphs with the same face.  */
       int face_id = string->face_id;
-      struct frame *face_id_frame = string->frame;
+      /* FIXME/tty: it happens that a single glyph's frame is NULL.  It
+	 might depend on a tab bar line being present, then switching
+	 from a buffer without header line to one with header line and
+	 opening a child frame.  */
+      struct frame *face_id_frame = string->frame ? string->frame : f;
 
       for (n = 1; n < stringlen; ++n)
 	if (string[n].face_id != face_id || string[n].frame != face_id_frame)
-- 
2.42.0






             reply	other threads:[~2024-11-08  6:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08  6:31 Gong Qijian [this message]
2024-11-09  4:15 ` bug#74274: [PATCH] Revert part of d3f8ed730f to avoid segmentation fault Gerd Möllmann
2024-11-09  6:10   ` qijian gong
2024-11-09  6:59     ` Gerd Möllmann
2024-11-09  7:23       ` Gerd Möllmann
2024-11-09  8:02         ` Gerd Möllmann
2024-11-09  8:17         ` Eli Zaretskii
2024-11-09  8:26           ` Gerd Möllmann
2024-11-10 10:56             ` Gerd Möllmann
2024-11-10 19:06               ` Gerd Möllmann

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=20241108063148.30423-3-gongqijian@gmail.com \
    --to=gongqijian@gmail.com \
    --cc=74274@debbugs.gnu.org \
    --cc=gerd@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 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).