GNU bug report logs - #37137
Setting font-lock-case-fold-search to t causes hangs on certain types in c-mode

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs,cc-mode; Reported by: Zachary Napier <zachary.napier.44@HIDDEN>; dated Wed, 21 Aug 2019 23:11:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 37137 <at> debbugs.gnu.org:


Received: (at 37137) by debbugs.gnu.org; 25 Aug 2019 11:15:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Aug 25 07:15:18 2019
Received: from localhost ([127.0.0.1]:43670 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1i1qUQ-0001mV-77
	for submit <at> debbugs.gnu.org; Sun, 25 Aug 2019 07:15:18 -0400
Received: from colin.muc.de ([193.149.48.1]:64862 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1i1qUN-0001mL-7V
 for 37137 <at> debbugs.gnu.org; Sun, 25 Aug 2019 07:15:16 -0400
Received: (qmail 52675 invoked by uid 3782); 25 Aug 2019 10:22:26 -0000
Date: 25 Aug 2019 10:22:26 -0000
Message-ID: <20190825102226.52674.qmail@HIDDEN>
From: Alan Mackenzie <acm@HIDDEN>
To: Zachary Napier <zachary.napier.44@HIDDEN>
Subject: Re: bug#37137: Setting font-lock-case-fold-search to t causes hangs
 on certain types in c-mode
Organization: muc.de e.V.
In-Reply-To: <mailman.18.1566429065.1922.bug-gnu-emacs@HIDDEN>
X-Newsgroups: gnu.emacs.bug
User-Agent: tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.2-RELEASE-p9
 (amd64))
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 37137
Cc: 37137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Zachary.

In article <mailman.18.1566429065.1922.bug-gnu-emacs@HIDDEN> you wrote:
> [-- text/plain, encoding 7bit, charset: UTF-8, 31 lines --]

> I have in my .emacs file only these two lines:

>     (custom-set-variables
>      '(font-lock-keywords-case-fold-search t))

May I ask why you're making this setting?

I think font-lock-keywords-case-fold-search is really intended to be set
by major modes, rather than as a user customisation.

> Then if I visit an empty or nonexistent C file and just type "LONG"
> (in all caps or with at least one letter being capital), Emacs will
> hang after typing the final G but before the G appears on
> screen. Typing C-g a couple of times gets Emacs unstuck until I
> continue to type. The same behavior also happens if I type "SHORT".

Yes.  The keywords in all the CC Mode languages are case sensitive.

Almost exactly the same bug came up in 2013, when the solution was to
bind case-fold-search to nil at every "entry point" to CC Mode.  I missed
font-lock-keywords-case-fold-search at the time.

> This happens in both Emacs 26.1 in text mode on a Linux machine and in
> Emacs 25.3 in GUI mode on Windows.

> After messing with GDB a bit, I am pretty sure the hang is at the
> while loop in c-forward-type at cc-engine.el:7657 and its getting
> stuck because looking-at matches LONG because its case insensitive,
> but the c-forward-keyword-clause doesn't move forward because the
> first thing it does is try to find "LONG" in c-keywords-obarray via
> `intern-soft` and immediately returns because it doesn't find it
> there. Here is the while loop:

>     (while (progn
>              (setq safe-pos (point))
>              (looking-at c-opt-type-component-key))
>       (when (and c-record-type-identifiers
>                  (looking-at c-primitive-type-key))
>         (c-record-type-id (cons (match-beginning 1)
>                                 (match-end 1))))
>       (c-forward-keyword-clause 1))

That's an excellent piece of debugging.  :-)

I think the best fix for the bug would be for CC Mode to set
font-lock-keywords-case-fold-search explicitly to nil (buffer locally) at
C Mode (etc.) initialisation.  This would undo the effect of your
custom-set-variables form in C Mode buffers.  Would this be a problem?

-- 
Alan Mackenzie (Nuremberg, Germany).





Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#37137; Package emacs,cc-mode. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 21 Aug 2019 23:10:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 21 19:10:27 2019
Received: from localhost ([127.0.0.1]:36785 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1i0ZkI-0006Ul-HH
	for submit <at> debbugs.gnu.org; Wed, 21 Aug 2019 19:10:27 -0400
Received: from lists.gnu.org ([209.51.188.17]:47212)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zachary.napier.44@HIDDEN>) id 1i0Yy3-00012T-FP
 for submit <at> debbugs.gnu.org; Wed, 21 Aug 2019 18:20:35 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:38949)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <zachary.napier.44@HIDDEN>) id 1i0Yy2-0001gA-6X
 for bug-gnu-emacs@HIDDEN; Wed, 21 Aug 2019 18:20:35 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: *
X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50,
 FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <zachary.napier.44@HIDDEN>) id 1i0Yy1-0001Ji-3F
 for bug-gnu-emacs@HIDDEN; Wed, 21 Aug 2019 18:20:34 -0400
Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]:41554)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <zachary.napier.44@HIDDEN>)
 id 1i0Yy0-0001JA-TI
 for bug-gnu-emacs@HIDDEN; Wed, 21 Aug 2019 18:20:33 -0400
Received: by mail-io1-xd35.google.com with SMTP id j5so7859144ioj.8
 for <bug-gnu-emacs@HIDDEN>; Wed, 21 Aug 2019 15:20:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=iARbKtPn2BqYoX5XJwjWwKcuH+OPlkmRYOvtnRfZ4v0=;
 b=sHs1/xBCrjvM+ZPOPVw2gSQ184N54hcqxBUZ4QnN/Zn61nZtVAtuToRKqJqmIiP16L
 +b8ZeIHQJJu2YNxtKGU01A8mqRqRa6pB5L17XL1IS2HG3SHXTbwWJZsm+pFwAblrO1I8
 Yq1Ss1hAlHig+PlzN0tNrIIhhBNvsMBJocgY9IazhdipHmn3v8qAv9LMWbcsGoznu2uC
 S10PU8D4zPOGxkNceCoh1N1oFmXQwtxquMUAHMYqdW8LDsD0B0nmJFAC9Ne9D0gpoZox
 MWeqIXdPjbKaCqobnRfWPyC6xu/kpoE47gP3HyvNaG5hqHtkBMAoBaG9sLWpoVsO3XYv
 WzmQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=iARbKtPn2BqYoX5XJwjWwKcuH+OPlkmRYOvtnRfZ4v0=;
 b=f3HH5A/p95f9Dc38siFeDsVXgr4YU2PSpLdCg9o0iLEbEWXuL1HkhuMFcmkBLJoxR/
 tw1nOfWHBoDXchkivXs4BPA0AjhryecbyFNWQndvXnOzLHZh0XQ+j4zUENB7fxMb3+yT
 7OflYyGB/Ad/dhPItiJAVP/nInOM9TlmoHwopWDsydNd0Cristpin/oBsSEn+dN2QDhZ
 QkC1X6urc/yRLHa+VKPrEhxMA5hDiQhwa8zM0UmtF9LwjDvaT9kB4u3SUdmXXiGJMQbt
 1bN5c8cxGfSdv21rvVfWFRNjM3b4KY4kl5xK53Mn2M2yFGBaTiwztFE8WzGAlhWtbJZL
 SwLw==
X-Gm-Message-State: APjAAAVpUKrUorIglWE7tXGTpsXa1aucPXW71i05Jov2riXkHLTJzoxQ
 3cDhyG7xUMTtuIWSgy8BsAKkEgaNSiTVgBvfnPgjaUo8dAg=
X-Google-Smtp-Source: APXvYqyawlSfG5kQ9Uqr+4KFa+9cglzy0JuSvIuJTx9d7IS4moCyMK4gVWhlWSgevmDmxKihjI0qzbtcjhGV+irFXts=
X-Received: by 2002:a6b:3ed4:: with SMTP id
 l203mr40958725ioa.275.1566426031417; 
 Wed, 21 Aug 2019 15:20:31 -0700 (PDT)
MIME-Version: 1.0
From: Zachary Napier <zachary.napier.44@HIDDEN>
Date: Wed, 21 Aug 2019 15:20:20 -0700
Message-ID: <CAOtOpxJ4FcAiujM=0oE326e8F-k9JPiMHwCvXCYEFFtR3ZxqQQ@HIDDEN>
Subject: Setting font-lock-case-fold-search to t causes hangs on certain types
 in c-mode
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="0000000000002b6eca0590a7fbf6"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2607:f8b0:4864:20::d35
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 21 Aug 2019 19:10:24 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

--0000000000002b6eca0590a7fbf6
Content-Type: text/plain; charset="UTF-8"

I have in my .emacs file only these two lines:

    (custom-set-variables
     '(font-lock-keywords-case-fold-search t))

Then if I visit an empty or nonexistent C file and just type "LONG"
(in all caps or with at least one letter being capital), Emacs will
hang after typing the final G but before the G appears on
screen. Typing C-g a couple of times gets Emacs unstuck until I
continue to type. The same behavior also happens if I type "SHORT".

This happens in both Emacs 26.1 in text mode on a Linux machine and in
Emacs 25.3 in GUI mode on Windows.

After messing with GDB a bit, I am pretty sure the hang is at the
while loop in c-forward-type at cc-engine.el:7657 and its getting
stuck because looking-at matches LONG because its case insensitive,
but the c-forward-keyword-clause doesn't move forward because the
first thing it does is try to find "LONG" in c-keywords-obarray via
`intern-soft` and immediately returns because it doesn't find it
there. Here is the while loop:

    (while (progn
             (setq safe-pos (point))
             (looking-at c-opt-type-component-key))
      (when (and c-record-type-identifiers
                 (looking-at c-primitive-type-key))
        (c-record-type-id (cons (match-beginning 1)
                                (match-end 1))))
      (c-forward-keyword-clause 1))

--0000000000002b6eca0590a7fbf6
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I have in my .emacs file only these two lines:<br><br>=C2=
=A0 =C2=A0 (custom-set-variables<br>=C2=A0 =C2=A0 =C2=A0&#39;(font-lock-key=
words-case-fold-search t))<br><br>Then if I visit an empty or nonexistent C=
 file and just type &quot;LONG&quot;<br>(in all caps or with at least one l=
etter being capital), Emacs will<br>hang after typing the final G but befor=
e the G appears on<br>screen. Typing C-g a couple of times gets Emacs unstu=
ck until I<br>continue to type. The same behavior also happens if I type &q=
uot;SHORT&quot;.<br><br>This happens in both Emacs 26.1 in text mode on a L=
inux machine and in<br>Emacs 25.3 in GUI mode on Windows.<br><br>After mess=
ing with GDB a bit, I am pretty sure the hang is at the<br>while loop in c-=
forward-type at cc-engine.el:7657 and its getting<br>stuck because looking-=
at matches LONG because its case insensitive,<br>but the c-forward-keyword-=
clause doesn&#39;t move forward because the<br>first thing it does is try t=
o find &quot;LONG&quot; in c-keywords-obarray via<br>`intern-soft` and imme=
diately returns because it doesn&#39;t find it<br>there. Here is the while =
loop:<br><br>=C2=A0 =C2=A0 (while (progn<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0(setq safe-pos (point))<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0(looking-at c-opt-type-component-key))<br>=C2=A0 =C2=A0 =
=C2=A0 (when (and c-record-type-identifiers<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(looking-at c-primitive-type-key))<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 (c-record-type-id (cons (match-beginning 1)<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (match-end 1))))<br>=C2=A0 =C2=A0 =C2=A0=
 (c-forward-keyword-clause 1))<br></div>

--0000000000002b6eca0590a7fbf6--




Acknowledgement sent to Zachary Napier <zachary.napier.44@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#37137; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 25 Aug 2019 11:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.