From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#57804: An infinite loop in a `fontify-region' function causes Emacs to hang indefinitely Date: Fri, 16 Sep 2022 09:17:00 +0800 Message-ID: <87bkrgunhv.fsf@localhost> References: <87pmfx6h7y.fsf@gnus.org> <2b58b8f5429a6e3aecda@heytings.org> <834jx85tyv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12805"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , Eli Zaretskii , 57804@debbugs.gnu.org, Paul Pogonyshev To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 16 03:38:13 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oZ0J2-00039N-9A for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Sep 2022 03:38:12 +0200 Original-Received: from localhost ([::1]:34874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZ0J1-0006lW-5r for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Sep 2022 21:38:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZ0It-0006lN-6S for bug-gnu-emacs@gnu.org; Thu, 15 Sep 2022 21:38:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oZ0Is-0004UL-UY for bug-gnu-emacs@gnu.org; Thu, 15 Sep 2022 21:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oZ0Is-0000Z5-Hg for bug-gnu-emacs@gnu.org; Thu, 15 Sep 2022 21:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Sep 2022 01:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57804 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 57804-submit@debbugs.gnu.org id=B57804.16632922312114 (code B ref 57804); Fri, 16 Sep 2022 01:38:02 +0000 Original-Received: (at 57804) by debbugs.gnu.org; 16 Sep 2022 01:37:11 +0000 Original-Received: from localhost ([127.0.0.1]:41051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZ0I3-0000Y1-AN for submit@debbugs.gnu.org; Thu, 15 Sep 2022 21:37:11 -0400 Original-Received: from mail-oi1-f180.google.com ([209.85.167.180]:39478) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZ0I0-0000Xn-HN for 57804@debbugs.gnu.org; Thu, 15 Sep 2022 21:37:10 -0400 Original-Received: by mail-oi1-f180.google.com with SMTP id m130so4446575oif.6 for <57804@debbugs.gnu.org>; Thu, 15 Sep 2022 18:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date; bh=8Yj9etqNpFFW24jmMrQbtXllhDC29SY833kZsIOmOoU=; b=BMTdulb4e3tK1mK1PUThPV/ngSLQEKijPOLo68YfrSGDy3XU7xTRrZNWbidcpIR3QR QObIAOzTY21/g+arWuTWI4AT6KAg0Nj7uEYIAA5MSX9F6G15qihrl7V2QXtnv/iHIbck 7islhlyruEqGIA5QUiu1ZfBs1PofY7BlJpooVkPN02x71Se8J5QzAt+YAlOLNkv6+QQ+ H2tH/o68VXHuyfSU9FggpGBJ/hTz1LDDtABLM2bz2kKSsDA+l4Tx/gofiG3SjrV/coF0 byUvAO6+Zr2aMkOwzzODWXVpFp+gnBxCokXlDIK633n1fzDARvH38Od8zSrBXj4t/Be7 +R0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date; bh=8Yj9etqNpFFW24jmMrQbtXllhDC29SY833kZsIOmOoU=; b=W6l7NLBpLC4kf7fjIg6XtMThV8o/EjVsTf3KUk0eXaOlmmB11VeJ/0Hyqct/21E0W7 whz0kAYKjiGX0huVN+LcY65aJNnJOWDIdCnV+lJhBO78u1b4MrT0l0MFkWfAZr2Y8w9P dCNdt7vSOVSEy+TdLAlzcF8oWNfoJigqoO1y8ii7Nid2KkufcMLflY0SVOPEiQZImB+M wNwbSIyvpqCvgO/Y4g5sJ3XSeSBCht5Ti//VqK33FDAuZFjA8sOiCEW0PbS1FzwOA9NH Wp9aYR7h0/pq/FPS6kl57CEDekJoY4QHCmb/lDPAL4hwrM/b/j8AKug1hMaeYgzA3YSw BjJQ== X-Gm-Message-State: ACrzQf14YnLxvoIQrvSkYax0T3jlerOTRj1nW6R0fcxrwlsBV4/mpO7z UPq2CJOtUrOhiibmTPAp93GPgUYtv3c= X-Google-Smtp-Source: AMsMyM6xZGut+BBM8irU3G53jkBpNWz+BW9BkX2c2+lWE6ulmCqTYeXURTEu4lX+Kw3fxgZghiV3ZQ== X-Received: by 2002:a17:90b:164d:b0:202:69b3:1002 with SMTP id il13-20020a17090b164d00b0020269b31002mr2689072pjb.86.1663290965390; Thu, 15 Sep 2022 18:16:05 -0700 (PDT) Original-Received: from localhost ([1.83.155.65]) by smtp.gmail.com with ESMTPSA id b6-20020a170903228600b0017693bb573bsm13614395plh.219.2022.09.15.18.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 18:16:04 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:242674 Archived-At: Gregory Heytings writes: >> Depending on the mode being activated before Emacs decides to enable the >> optimization (e.g. because one of the first lines is very long, I don't >> know how exactly this is determined) seems very shaky. > > Indeed. As I told you the proper fix is not to disable these > optimizations, but to adapt the code to handle locked narrowing, by > explicitly unlocking the locked narrowing when, and only when, it needs to > access a larger portion of the buffer. I would like to point out that some fontification code may use functions not specifically designed for the fontification. Moreover, the functions used by fontification may depend on user-defined hooks that can potentially contain unsuspecting (widen) calls. While I understand why locked narrowing is needed in buffers with large files, I would find it helpful if Emacs could throw some kind of warning when widen is called from inside locked narrowing. It will, at least, help with adapting the existing fontification code in the new Emacs versions. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92