From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#68546: 29.1.90; end-of-file has incorrect data when signaled within a load Date: Thu, 25 Jan 2024 09:12:50 -0500 Message-ID: References: <797f3211-068f-4b7f-bb34-f3c9ee12241b@gutov.dev> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000ff0fb6060fc5c6ea" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32011"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68546@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 25 15:14:13 2024 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 1rT0Uf-00085t-4I for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Jan 2024 15:14:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT0UQ-0007aF-Nn; Thu, 25 Jan 2024 09:13:58 -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 1rT0UP-0007a7-2U for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 09:13:57 -0500 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 1rT0UO-00085C-Py for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 09:13:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rT0UU-0001A6-9p for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 09:14:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jan 2024 14:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68546 X-GNU-PR-Package: emacs Original-Received: via spool by 68546-submit@debbugs.gnu.org id=B68546.17061919964404 (code B ref 68546); Thu, 25 Jan 2024 14:14:02 +0000 Original-Received: (at 68546) by debbugs.gnu.org; 25 Jan 2024 14:13:16 +0000 Original-Received: from localhost ([127.0.0.1]:47674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rT0Tj-00018x-WA for submit@debbugs.gnu.org; Thu, 25 Jan 2024 09:13:16 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:49619) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rT0Ti-00018d-E3 for 68546@debbugs.gnu.org; Thu, 25 Jan 2024 09:13:15 -0500 Original-Received: from mail-ej1-f69.google.com ([209.85.218.69]) by mxgoog2.mail.janestreet.com with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) (Exim 4.97.1) id 1rT0TY-0000000BNNu-19jR for 68546@debbugs.gnu.org; Thu, 25 Jan 2024 09:13:02 -0500 Original-Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a2f1d0c3389so247036066b.0 for <68546@debbugs.gnu.org>; Thu, 25 Jan 2024 06:13:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; t=1706191982; x=1706796782; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2GKDcVy4qEfl0MBhRgumxd07ueg6iND526oG1lT7vtM=; b=L0JmTKCKcS9Pm49/4dL+TphgjHN+VnKHhpNtKopi9eubrWXtWiQ13YZ9FvGgGYVk98 da0cR+TvckigWC9ZbELLhjiFnXBxrr6hImOrd+/6yR9bAIPQg/Q3dLTnOMzwLQv5toAS gdr85/z0B8t3pO+532HGFkk6DAuqqeZHrnujg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1706191982; bh=2GKDcVy4qEfl0MBhRgumxd07ueg6iND526oG1lT7vtM=; h=References:In-Reply-To:From:Date:Subject:To:Cc; b=LSBSF40RRhEoGFhaLzUnTc6rIJ80Wf68PPmcF3BMKLBUoOMHG2KDoQl+zD3MXD4TB xMpC3qVuFcHAtABuXXc5W7rBw2fRwh1hIR+SvqgrPkrXduUmfWG4oXceF3sqxdcn8r t+kXujNutWXcFPO+S72UmBw7MlYbfsGPWLzs9rAlkyx10MaNIy2qr6cu4RJNi1jW7O TshqHMEq/eQJh6DocYl2MEoc1sI4rx1tLTzrPLmyjNGgjBo1z7f6n9F32Q36Y/h1Mu J6XXOQ1tvlbFTWN7Di6HrbEX7lt6WQbXh6tAAyzNwEBAdHNGJjmP9fb26j6gWpw63H oHkcWCjzFcu9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706191982; x=1706796782; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2GKDcVy4qEfl0MBhRgumxd07ueg6iND526oG1lT7vtM=; b=RPkRWP4E0fG47AvBmDcZeK5HaympYX9o4mhubxyOlQ0TJSW58myBikUwWCnw/ToooQ Bgm08mQNNp/Ay8gVkyZDV9PF4Im09IUbTCP9qRZzeES+ry2cqYovZVJnRWRyrf/pwpYL uQzTZUtwoaYfwhCdmwq78hGejtCvVLHSJ+Hl5o+PWVFlEo2sy77owKLmZ6EBbr2NKPs1 GF+h06f/Vz7V/PxPhzBS9PRCQrUZ3DMnhJmH9iRAoU82JdUDJ6kuqLzp68ZUxvBoBwnC Yv9PbWRXsBxdO+9ymDN7X11XgdabJRtJIyCPZeSUkJdfu1lT1+Jn3DBT1wrvX6AgLkED tJ1g== X-Gm-Message-State: AOJu0YxtS/k4nuSv4IkJhE9H79VcUofDqRpV75W2mOyiUQZ+0o7SAAWD 99VIHAWuF5MQb0CF1ppiYWkxdC53jnhU/vZNxDjTiQqXBANmjWPvm40VAagZbJd5J+gKsg7u3LJ 9Q2UlRLtSLdHuEiIRlO3C1epu1zLVeem/6R40wm65N5+aLIXsulkLANAggQNW8g2tDiJp+h9AmG Jx8PUZ0lm6g5abZ/Oy1qc/wDBa3A== X-Received: by 2002:a17:907:a808:b0:a31:7ce5:d44b with SMTP id vo8-20020a170907a80800b00a317ce5d44bmr676049ejc.71.1706191982154; Thu, 25 Jan 2024 06:13:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBZNWwh70adSPgDCwLQKR6lWGKiRLZeqFtwOwe7kavv+VNnTHOfN9wbeLjxB0BNwOsSzn6zMCh8jQjMhi69I0= X-Received: by 2002:a17:907:a808:b0:a31:7ce5:d44b with SMTP id vo8-20020a170907a80800b00a317ce5d44bmr676038ejc.71.1706191981837; Thu, 25 Jan 2024 06:13:01 -0800 (PST) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:278852 Archived-At: --000000000000ff0fb6060fc5c6ea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 25, 2024 at 9:05=E2=80=AFAM Spencer Baugh wrote: > On Wed, Jan 17, 2024 at 3:55=E2=80=AFPM Dmitry Gutov w= rote: > >> On 17/01/2024 21:04, Spencer Baugh wrote: >> > As one particular example of the confusing current behavior, a user ha= d >> > corrupted their ~/.emacs.d/projects so that reading it failed. Also, >> > they had a call to (project-forget-zombie-projects) in their init.el. >> > In combination, this meant Emacs startup errored with: >> > >> > End of file during parsing:/home/user/.emacs.d/init.el >> > >> > even though there was no syntax error in init.el at all. >> >> Would something like this help with this particular sub-problem? >> >> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el >> index a6f14a0865c..196a82757b2 100644 >> --- a/lisp/progmodes/project.el >> +++ b/lisp/progmodes/project.el >> @@ -1694,7 +1694,9 @@ project--read-project-list >> (let ((name (car elem))) >> (list (if (file-remote-p name) name >> (abbreviate-file-name name))))) >> - (read (current-buffer)))))) >> + (condition-case nil >> + (read (current-buffer)) >> + (end-of-file (warn "Failed to read the projects list >> file"))))))) >> (unless (seq-every-p >> (lambda (elt) (stringp (car-safe elt))) >> project--list) >> >> > Yes, I think that would be great. Especially because this allows startup > to continue. If it's okay with you too, I think it's reasonable to push. > > This de-facto resets the contents of the projects list file (since the > corrupted version will get saved over), but I think that's fine - it's n= ot > especially hard information to rebuild, and if it's corrupt anyway then > it's probably already at least partially lost (in my case, a user had an > empty projects file for some reason, not sure why). Oh and I guess we > already reset the contents if it's in the wrong format. So yeah, this > seems great. > Ah, I think the cause (in at least one case) is that the user ran out of disk space, and so the write-region call in project--write-project-list failed when writing, which happens after truncating the existing file. I guess there should be some atomic version of write-region which writes to a temp file and renames it over the original. --000000000000ff0fb6060fc5c6ea Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Jan 25, 2024 at 9:05=E2=80=AFAM S= pencer Baugh <sbaugh@janestreet= .com> wrote:
On Wed, Jan = 17, 2024 at 3:55=E2=80=AFPM Dmitry Gutov <dmitry@gutov.dev> wrote:
On 17/01/2024 21:04, Spencer Baugh = wrote:
> As one particular example of the confusing current behavior, a user ha= d
> corrupted their ~/.emacs.d/projects so that reading it failed.=C2=A0 A= lso,
> they had a call to (project-forget-zombie-projects) in their init.el.<= br> > In combination, this meant Emacs startup errored with:
>
> End of file during parsing:/home/user/.emacs.d/init.el
>
> even though there was no syntax error in init.el at all.

Would something like this help with this particular sub-problem?

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index a6f14a0865c..196a82757b2 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1694,7 +1694,9 @@ project--read-project-list
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let (= (name (car elem)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(list (if (file-remote-p name) name
=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(abbreviate-file-name name)))))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(read (current-buff= er))))))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(condition-case nil=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(read= (current-buffer))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(end-of-file= (warn "Failed to read the projects list
file")))))))
=C2=A0 =C2=A0 =C2=A0 (unless (seq-every-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda (elt) (strin= gp (car-safe elt)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0project--list)


Yes, I think that would be great.=C2= =A0 Especially because this allows startup to continue.=C2=A0 If it's o= kay with you too, I think it's reasonable to push.

=
This de-facto resets the contents of the projects list file (since the= corrupted version will get saved over), but I think=C2=A0that's fine -= =C2=A0 it's not especially hard information to rebuild, and if it's= corrupt anyway then it's probably already at least partially lost (in = my case, a user had an empty projects file for some reason, not sure why).= =C2=A0 Oh and I guess we already reset the contents if it's in the wron= g format.=C2=A0 So yeah, this seems great.

Ah, I think the cause (in at least one case) is that the = user ran out of disk space, and so the write-region call in=C2=A0project--w= rite-project-list failed when writing, which happens after truncating the e= xisting file.=C2=A0 I guess there should be some atomic version of write-re= gion which writes to a temp file and renames it over the original.
--000000000000ff0fb6060fc5c6ea--