From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#38564: 27.0.50; macOS "emacs -nw" git-gutter-mode segfault Date: Wed, 11 Dec 2019 11:12:41 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="207092"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38564@debbugs.gnu.org To: Mike Hamrick Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 11 11:13:09 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ieyzV-000rkc-Mu for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Dec 2019 11:13:09 +0100 Original-Received: from localhost ([::1]:40464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieyzU-0004TV-I3 for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Dec 2019 05:13:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59131) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieyzP-0004TL-9V for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2019 05:13:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieyzO-0000a3-5L for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2019 05:13:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50944) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieyzN-0000ZD-Tr for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2019 05:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ieyzN-0006On-NL for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2019 05:13:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Dec 2019 10:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38564 X-GNU-PR-Package: emacs Original-Received: via spool by 38564-submit@debbugs.gnu.org id=B38564.157605917224581 (code B ref 38564); Wed, 11 Dec 2019 10:13:01 +0000 Original-Received: (at 38564) by debbugs.gnu.org; 11 Dec 2019 10:12:52 +0000 Original-Received: from localhost ([127.0.0.1]:56917 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieyzD-0006OP-Ok for submit@debbugs.gnu.org; Wed, 11 Dec 2019 05:12:52 -0500 Original-Received: from mail-wm1-f45.google.com ([209.85.128.45]:53251) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieyzB-0006OC-Pw for 38564@debbugs.gnu.org; Wed, 11 Dec 2019 05:12:50 -0500 Original-Received: by mail-wm1-f45.google.com with SMTP id n9so6403465wmd.3 for <38564@debbugs.gnu.org>; Wed, 11 Dec 2019 02:12:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:gmane-reply-to-list:date:message-id :mime-version:content-transfer-encoding; bh=yRAit1IdBPWLVLOOFMXVP2maSjztaO/F5effBxkpBm8=; b=WxSYRCJBKFgoXplbohNfsFboAN1L762naFZSHVJLqBBmsd7eFV4eln410QvhEFHEA0 dtC+p7Pa+yVsjsF9bZwR7n9diWCTSxTiGuseCv4JOI9mzuGfz4jd8MYOjlkDKVXWThh5 HfB2r9ldk1q8Hq2pEcm1dUuYG5fY5FCF024hHyKwi00yf3QWl2LA2pofCQIXupfBFP7h /94HcbDiPhw/cv8zZaQdilOcor1R3EVkrARRGfkPDEJgw5/9yWIbrC2KyMJXH+dVcgX7 OQiYs26jjDpsZcYv/XwOmHfSvhDjFKXk37zFoPwf4M4h/+QgqUIm01pI+larjZ7B2cXx A60Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:message-id:mime-version :content-transfer-encoding; bh=yRAit1IdBPWLVLOOFMXVP2maSjztaO/F5effBxkpBm8=; b=pGqWJ9AIbcUNMMSh9CKYehlXMzMdOP70eo+FrveU2COrTX1YaP1QxGm9Biwznf+hMz yi8+2FMWy4ud+NhBEME1NnysGMCHerFW7KItux5yC7RFbjdAiboh3K7pVyzkVK6z97GO 8Cy+tsWB6fw0+tKXiaFmDcFjLLpxFHYDorde8GfOJvPSOkWFMkcv54hk4jH4hc2A37Z+ MW2fGr90oDFHDNQHVUuLZ3txhofiZ2z37KpGKlcZG6ASNI/jsq9TC2IMeaa2xm4ks1iE J1IyYLOmaBcXsA/ChjwFA3hp8hHwWnlCArsXd889X2ff7jxDxBpuXtEAZ6GOBfSg16Pu 1c4Q== X-Gm-Message-State: APjAAAUyzf1UbNm6yOPvi/L5rLoWghHqrTFe5iW3lWMTfqzNrrOiAx2y f8VRyZNEfm9BLdbCMWc+IFBj83azslM= X-Google-Smtp-Source: APXvYqyhxM2Im+Hw7ZUJcyvBzVzjSunsDyJEoC69EsafCnkIjqLU4PjVpDnjlIdbHrXAfLIb16jAeA== X-Received: by 2002:a7b:cf2d:: with SMTP id m13mr2675841wmg.163.1576059163232; Wed, 11 Dec 2019 02:12:43 -0800 (PST) Original-Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id s65sm1735450wmf.48.2019.12.11.02.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 02:12:42 -0800 (PST) Gmane-Reply-To-List: yes X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173175 Archived-At: >>>>> On Tue, 10 Dec 2019 17:33:37 -0800, Mike Hamrick 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=CA=BCm 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(id= x=3D18446744073709551613, f=3D0x00007facab80e210) at nsterm.m:2097:64 Mike> frame #1: 0x000000010416b5fc emacs`ns_color_index_to_rgba(idx= =3D-3, f=3D0x00007facab80e210) 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) =3D=3D nil) Mike> + return nil; Mike> struct ns_color_table *color_table =3D FRAME_DISPLAY_INFO (f)-= >color_table; Mike> if (idx < 1 || idx >=3D 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 syst= em. */ =20 /* 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*/ =20 unsigned long ns_color_index_to_rgba(int idx, struct frame *f) { - NSColor *col; - col =3D ns_lookup_indexed_color (idx, f); + if (FRAME_DISPLAY_INFO (f)) + { + NSColor *col; + col =3D ns_lookup_indexed_color (idx, f); =20 - 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]; =20 - 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; } =20 void