all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Mike Hamrick <mikeh@muppetlabs.com>
Cc: 38564@debbugs.gnu.org
Subject: bug#38564: 27.0.50; macOS "emacs -nw" git-gutter-mode segfault
Date: Wed, 11 Dec 2019 11:12:41 +0100	[thread overview]
Message-ID: <m27e33yxuu.fsf@gmail.com> (raw)
In-Reply-To: <m1immnir2m.fsf@eidolon.muppetlabs.com>

>>>>> On Tue, 10 Dec 2019 17:33:37 -0800, Mike Hamrick <mikeh@muppetlabs.com> said:

    Mike> Hi there,
    Mike> Here is how I got emacs to segfault and drop be back to the shell:
    Mike> - compile emacs 27.0.50 under macOS
    Mike> - install the git-gutter package
    Mike> - set up an after-init-hook for global-git-gutter-mode
    Mike> - emacs -nw /some/file/under/version/control

Iʼm surprised nobody's seen this before.

    Mike> The relevant part of my init.el looks like:
    >> (use-package git-gutter
    >> :ensure t
    >> :init
    >> (add-hook 'after-init-hook 'global-git-gutter-mode))

    Mike>   * frame #0: 0x000000010416ab3e emacs`ns_lookup_indexed_color(idx=18446744073709551613, f=0x00007facab80e210) at nsterm.m:2097:64
    Mike>     frame #1: 0x000000010416b5fc emacs`ns_color_index_to_rgba(idx=-3, f=0x00007facab80e210) at nsterm.m:2299:9

    Mike> diff --git a/src/nsterm.m b/src/nsterm.m
    Mike> index c415159890..ea2b141d95 100644
    Mike> --- a/src/nsterm.m
    Mike> +++ b/src/nsterm.m
    Mike> @@ -2094,6 +2094,8 @@ so some key presses (TAB) are swallowed by the system.  */
    Mike>  NSColor *
    Mike>  ns_lookup_indexed_color (unsigned long idx, struct frame *f)
    Mike>  {
    Mike> +  if (FRAME_DISPLAY_INFO (f) == nil)
    Mike> +    return nil;
    Mike>    struct ns_color_table *color_table = FRAME_DISPLAY_INFO (f)->color_table;
    Mike>    if (idx < 1 || idx >= color_table->avail)
    Mike>      return nil;

Right idea, but one layer lower than needed. ns_color_index_to_rgba
should not be calling ns_lookup_indexed_color in non-gui mode. Try
this instead:

diff --git a/src/nsterm.m b/src/nsterm.m
index 52a9830be8..814a090370 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2290,19 +2290,24 @@ so some key presses (TAB) are swallowed by the system.  */
 
 /* Convert an index into the color table into an RGBA value.  Used in
    xdisp.c:extend_face_to_end_of_line when comparing faces and frame
-   color values.  */
+   color values.  No-op on non-gui frames*/
 
 unsigned long
 ns_color_index_to_rgba(int idx, struct frame *f)
 {
-  NSColor *col;
-  col = ns_lookup_indexed_color (idx, f);
+  if (FRAME_DISPLAY_INFO (f))
+    {
+      NSColor *col;
+      col = ns_lookup_indexed_color (idx, f);
 
-  EmacsCGFloat r, g, b, a;
-  [col getRed: &r green: &g blue: &b alpha: &a];
+      EmacsCGFloat r, g, b, a;
+      [col getRed: &r green: &g blue: &b alpha: &a];
 
-  return ARGB_TO_ULONG((int)(a*255),
-                       (int)(r*255), (int)(g*255), (int)(b*255));
+      return ARGB_TO_ULONG((int)(a*255),
+                           (int)(r*255), (int)(g*255), (int)(b*255));
+    }
+  else
+    return idx;
 }
 
 void





  reply	other threads:[~2019-12-11 10:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-11  1:33 bug#38564: 27.0.50; macOS "emacs -nw" git-gutter-mode segfault Mike Hamrick
2019-12-11 10:12 ` Robert Pluim [this message]
2019-12-11 15:15   ` Mike Hamrick
2019-12-11 15:35     ` Robert Pluim
2019-12-11 19:37   ` Alan Third
2019-12-12  7:45     ` Robert Pluim
2019-12-19 19:20       ` Alan Third
2019-12-19 18:03 ` Mike Hamrick
2019-12-19 19:14   ` Alan Third
2019-12-20 11:47     ` Robert Pluim
2019-12-20 20:21       ` Mike Hamrick
2019-12-29 20:41         ` Robert Pluim

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=m27e33yxuu.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=38564@debbugs.gnu.org \
    --cc=mikeh@muppetlabs.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 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.