From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Test to determine character left-overhangs a tab stretch. Date: Wed, 14 Nov 2018 17:33:56 +0200 Message-ID: <838t1v8yhn.fsf@gnu.org> References: NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1542209595 27962 195.159.176.226 (14 Nov 2018 15:33:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 14 Nov 2018 15:33:15 +0000 (UTC) Cc: emacs-devel@gnu.org To: Keith David Bershatsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 14 16:33:10 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gMxAB-00075j-QK for ged-emacs-devel@m.gmane.org; Wed, 14 Nov 2018 16:33:07 +0100 Original-Received: from localhost ([::1]:32787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMxCH-0006kd-Ns for ged-emacs-devel@m.gmane.org; Wed, 14 Nov 2018 10:35:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMxB4-0006jO-4f for emacs-devel@gnu.org; Wed, 14 Nov 2018 10:34:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMxB1-0005KI-H9 for emacs-devel@gnu.org; Wed, 14 Nov 2018 10:34:02 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMxB1-0005K1-Di; Wed, 14 Nov 2018 10:33:59 -0500 Original-Received: from [176.228.60.248] (port=4972 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gMxB0-0003Cg-Hr; Wed, 14 Nov 2018 10:33:59 -0500 In-reply-to: (message from Keith David Bershatsky on Tue, 13 Nov 2018 12:57:08 -0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:231130 Archived-At: > Date: Tue, 13 Nov 2018 12:57:08 -0800 > From: Keith David Bershatsky > Cc: emacs-devel@gnu.org > > Thank you Eli for helping out with this particular issue. I think the problem is that first_glyph->type (in the following test) is sometimes invalid and that is what causes the crash. The test is designed to skip over the area of code when a tab stretch would normally be drawn anew due to the next glyph having a left overhang. > > Last Commit : Tue Nov 13 22:01:57 2018 +0200 > : Eli Zaretskii > : 4a5a17507fe1e12ee02c174350edc479fb01ac01 > : Fix recent change in fileio.c > > diff --git a/src/xdisp.c b/src/xdisp.c > index fa7691c..198a516 100644 > --- a/src/xdisp.c > +++ b/src/xdisp.c > @@ -26841,7 +26841,45 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row, > prepended must be drawn because the first glyph string > draws over it. */ > i = left_overwritten (head); > - if (i >= 0) left_overwritten can return a negative value, in which case this: > + bool skip_p = false; > + int beg = i; > + > + if (hl == DRAW_CURSOR) > + while (beg < start) > + { > + struct glyph *first_glyph = (row)->glyphs[area] + beg; > + if (first_glyph != NULL > + && first_glyph->type != NULL) attempts to dereference a pointer that is before the beginning of row->glyphs[area], and you get a segfault. I think your code should be inside the "if (i >= 0)" clause. Stepping back, I'm not sure what you do is a good idea. Redrawing neighboring glyphs due to overhanging is done for a reason, so skipping it might well produce incorrect display. I advice against that.