From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#66759: 30.0.50; Flymake (with Eglot) error cleaning up old overlay Date: Thu, 26 Oct 2023 14:27:42 +0100 Message-ID: <87pm111pkh.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14025"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66759@debbugs.gnu.org To: Richard Copley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 26 15:25:54 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 1qw0My-0003Mk-Tc for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Oct 2023 15:25:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qw0Mh-0006hg-Jo; Thu, 26 Oct 2023 09:25:35 -0400 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 1qw0Me-0006h2-9L for bug-gnu-emacs@gnu.org; Thu, 26 Oct 2023 09:25:32 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qw0Me-00089X-16 for bug-gnu-emacs@gnu.org; Thu, 26 Oct 2023 09:25:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qw0N8-0007id-Nc for bug-gnu-emacs@gnu.org; Thu, 26 Oct 2023 09:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Oct 2023 13:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66759 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169832672829597 (code B ref -1); Thu, 26 Oct 2023 13:26:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Oct 2023 13:25:28 +0000 Original-Received: from localhost ([127.0.0.1]:60986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qw0MZ-0007hJ-Ki for submit@debbugs.gnu.org; Thu, 26 Oct 2023 09:25:28 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:51650) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qw0MV-0007h4-R9 for submit@debbugs.gnu.org; Thu, 26 Oct 2023 09:25:26 -0400 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 1qw0Lv-0006Yk-H8 for bug-gnu-emacs@gnu.org; Thu, 26 Oct 2023 09:24:47 -0400 Original-Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qw0Lt-0007rj-Rs for bug-gnu-emacs@gnu.org; Thu, 26 Oct 2023 09:24:47 -0400 Original-Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2b9d07a8d84so11785251fa.3 for ; Thu, 26 Oct 2023 06:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698326683; x=1698931483; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8EbyUzmqtt8vIL9/w151i8S+bvOsB88fGb9zsC1rRss=; b=ByVEpLdvjwz/0cnRYE5bFBaIlCjqCO+aARhRgwtXesU3krVKeTOCW2EFO3CSM5IF3I ifswQUBhGXk4EiAK5ySMtpDjIUJXHiSFVslPzQVLV2jBAuuvwOFD/6nUVEJvlGW++7vB Dfq+lvJdhgDzBkOSTU70BgEAWmTxBfYt8D16f2TZGOK97MhUOVeHkrIrSBOY2pn8hnta Ppw9yK8KHx+vbtlEixv7ih4OIsn9iZGF58sPDLcGfBs6ovtqqSO58OoXhchnp/Nxg/5o upj4z2iL80+NZldYqSYMjww1INAmIu8HgNQX4x5RPOOfUd+iNp63Vrpx8hNgFe4kd1x/ deSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698326683; x=1698931483; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8EbyUzmqtt8vIL9/w151i8S+bvOsB88fGb9zsC1rRss=; b=K8nItzBj+U15JXqDbY8oPiH8jPR4O+j0FYxTQJZ2W5JLQvyYvBhYtXHBzp8vmgl57l GyEeP7iIZKjQN5fQtnzGqzyZK2zNwN37LlC529fHRlfCjG2tv2odB26ID9bPCoSy4Beh Cz7JenN8Fyu6nkk0/O92uVB6m1hb55stoseqwA5hiIRffpPh/fX0EqYJOXqcB0rCFs3r fkkX7abCdvQ1DY9bKE8U4SFER6af3j15WGdjgRm0cDd6JA7NTMU8P1EwKKMyNqrjQRFu 2Z9b5YqFHal/ebQAsjy0yMmXT6fF/ApFX4EJ+O9qf5gnhNSkdqFjR4qrglAWnRyyBew8 kk0g== X-Gm-Message-State: AOJu0Yx3KWz5zvNuvPTnhHG0I0IKjdYpXg5uWpPU+u2S6BL4K1bUdVI7 XKW3+kl2vhuFlEWWRjCn4yEYxUWyfDytFA== X-Google-Smtp-Source: AGHT+IHLorgKc50POQpjlZ4rplVq0HjOIPUsL4ndLPkYxlg5F3ERp87LcBcaaNhpFd7KA7O8/PEe3g== X-Received: by 2002:a2e:99c8:0:b0:2c0:318a:6ee1 with SMTP id l8-20020a2e99c8000000b002c0318a6ee1mr12877955ljj.49.1698326683219; Thu, 26 Oct 2023 06:24:43 -0700 (PDT) Original-Received: from krug ([87.196.80.249]) by smtp.gmail.com with ESMTPSA id d17-20020a5d6451000000b0032da022855fsm14187118wrw.111.2023.10.26.06.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 06:24:42 -0700 (PDT) In-Reply-To: (Richard Copley's message of "Thu, 26 Oct 2023 13:09:07 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=joaotavora@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:273283 Archived-At: Richard Copley writes: > I'm afraid I'm unable to consistently reproduce this error. I hope you > can see the issue and devise a testcase from the following > description. Thanks very much for this report. This problem could be the same as https://github.com/joaotavora/eglot/discussions/1311, at least it its most recent iteration. Anyway, I think your analysis of the code is excellent and your conjecture (for at least one possible cause of this problem) is very promising. That "don't bother with invalid bounds" was introduced recently: commit 8b1947ffdd9d9eae26a308f0abaac45e06baac22 Author: Jo=C3=A3o T=C3=A1vora Date: Thu Sep 21 00:03:32 2023 +0100 =20=20=20=20 Flymake: more fixes to flymake--highlight-line =20=20=20=20=20=20=20 Make it robust to diagonstics with invalid bounds. =20=20=20=20=20=20=20 * lisp/progmodes/flymake.el (flymake--highlight-line): Robustify. =20=20=20=20 diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -781,1 +782,5 @@ - (setq ov (make-overlay end beg)) + (when (=3D (overlay-start ov) (overlay-end ov)) + ;; Some backends report diagnostics with invalid bounds. Don't + ;; bother. + (delete-overlay ov) + (cl-return-from flymake--highlight-line nil)): And indeed the flymake--diag-overlay slot is not filled in when we get this early return. And indeed the overlays considered for deletion are the ones stored in the "state" map, meaning everything the backend reported. So maybe this patch is all that's needed: diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index b27e6527f81..9be40499d37 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -809,6 +809,7 @@ flymake--highlight-line (flymake--diag-orig-end e)) (flymake--delete-overlay eov))) (setq ov (make-overlay beg end)) + (setf (flymake--diag-overlay diagnostic) ov) (when (=3D (overlay-start ov) (overlay-end ov)) ;; Some backends report diagnostics with invalid bounds. Don't ;; bother. @@ -863,7 +864,6 @@ flymake--highlight-line (overlay-put ov 'evaporate t) (overlay-put ov 'flymake-overlay t) (overlay-put ov 'flymake-diagnostic diagnostic) - (setf (flymake--diag-overlay diagnostic) ov) ;; Handle `flymake-show-diagnostics-at-end-of-line' ;; (when flymake-show-diagnostics-at-end-of-line There's a fair chance this fixes the bug effectively, but even if it doesn't, it is nevertheless a solid change, so I've pushed it and bumped the Flymake ELPA package version. Please keep an eye out of this bug. What language server are you using with Eglot btw? > A possible fix is to check if `flymake--highlight-line' created an > overlay before inserting a diagnostic into `flymake--state-diags', > in phase 2. This could also work, but is slightly more complex. And it would destroy the invariant that that list contains every "domestic" diagnostic reported by the backend (even invalid ones). Jo=C3=A3o