From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#61298: Emacs 29.0.60: font-lock throws an args-out-of-range error with a long line. Date: Sun, 5 Feb 2023 14:54:35 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2235"; mail-complaints-to="usenet@ciao.gmane.io" To: 61298@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 05 15:55:21 2023 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 1pOgQK-0000Nq-02 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Feb 2023 15:55:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOgQ5-0006RW-Cp; Sun, 05 Feb 2023 09:55:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOgQ2-0006RJ-9J for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 09:55:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pOgQ2-0005ff-11 for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 09:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pOgQ1-0001ra-Q2 for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 09:55:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Feb 2023 14:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61298 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16756088947136 (code B ref -1); Sun, 05 Feb 2023 14:55:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Feb 2023 14:54:54 +0000 Original-Received: from localhost ([127.0.0.1]:44475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOgPu-0001r2-6a for submit@debbugs.gnu.org; Sun, 05 Feb 2023 09:54:54 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:36756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOgPs-0001qu-Jr for submit@debbugs.gnu.org; Sun, 05 Feb 2023 09:54:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOgPs-00065b-D2 for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 09:54:52 -0500 Original-Received: from mx3.muc.de ([193.149.48.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOgPn-0005ei-Un for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 09:54:51 -0500 Original-Received: (qmail 79933 invoked by uid 3782); 5 Feb 2023 15:54:36 +0100 Original-Received: from acm.muc.de (p4fe1529c.dip0.t-ipconnect.de [79.225.82.156]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 05 Feb 2023 15:54:35 +0100 Original-Received: (qmail 19396 invoked by uid 1000); 5 Feb 2023 14:54:35 -0000 Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.5; envelope-from=acm@muc.de; helo=mx3.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254861 Archived-At: Hello, Emacs. This bug is reproducible in both the master branch and release branch as updated yesterday evening (European time). To reproduce this bug: (i) Apply this bug fix to CC Mode, and byte compile the defun (or file), and make sure it's loaded: diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 2631c24f8db..9fa727d9e1f 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -5915,19 +5915,21 @@ c-determine-limit (cond ((> pos start) ; Nothing but literals base) - ((> base (point-min)) + ((and + (> base (point-min)) + (> (- base try-size) (point-min))) ; prevent infinite recursion. (c-determine-limit how-far-back base (* 2 try-size) org-start)) (t base))) ((>= count how-far-back) (c-determine-limit-no-macro - (+ (car elt) (- count how-far-back)) - org-start)) + (+ (car elt) (- count how-far-back)) + org-start)) ((eq base (point-min)) (point-min)) ((> base (- start try-size)) ; Can only happen if we hit point-min. (c-determine-limit-no-macro - (car elt) - org-start)) + (car elt) + org-start)) (t (c-determine-limit (- how-far-back count) base (* 2 try-size) org-start)))))) (ii) M-: (setq backtrace-on-redisplay-error t) (iii) C-x b temp.cc. M-x c++-mode. (iv) Type in the following text: char foo [] = R"foo( )foo" (v) With point at the end of the first line in temp.cc, M-: (insert (make-string 260000 ?y)) This may take some time to execute. (vi) C-x 4 b *Redisplay_trace* The following backtrace will be seen: Error: args-out-of-range (260028 260028) mapbacktrace(#f(compiled-function (evald func args flags) #)) debug-early-backtrace() debug-early(error (args-out-of-range 260028 260028)) <=============== get-text-property(260028 font-lock-multiline) font-lock-extend-region-multiline() font-lock-default-fontify-region(1 260029 nil) c-font-lock-fontify-region(1 1501 nil) font-lock-fontify-region(1 1501) #f(compiled-function (fun) #)(font-lock-fontify-region) run-hook-wrapped(#f(compiled-function (fun) #) font-lock-fontify-region) jit-lock--run-functions(1 1501) jit-lock-fontify-now(1 1501) jit-lock-function(1) redisplay_internal\ \(C\ function\)() This is clearly a bug. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Position 260028 is within the bounds of the buffer. It would appear that the new-ish long-lines code has narrowed the buffer at some stage such that point-max is less than the end of the buffer. I propose the following simple patch which fixes (or works around) this bug: diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 1fa45379b9f..9e944fe188a 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1154,6 +1154,8 @@ font-lock-default-fontify-region "Fontify the text between BEG and END. If LOUDLY is non-nil, print status messages while fontifying. This function is the default `font-lock-fontify-region-function'." + (or (<= end (point-max)) + (setq end (point-max))) (with-silent-modifications ;; Use the fontification syntax table, if any. (with-syntax-table (or font-lock-syntax-table (syntax-table)) -- Alan Mackenzie (Nuremberg, Germany).