Subject: Re: bug#75209: 30.0.93; Emacs reader failed to read data in "/home/nlj/.cache/org-persist/gc-lock.eld"

From: Eli Zaretskii <[email-masked]>
Date: Wed, 01 Jan 2025 20:52:03 +0200

> Date: Wed, 01 Jan 2025 17:41:57 +0000
> From: Pip Cet <[email-masked]>
> Cc: "N. Jackson" <[email-masked]>, [email-masked], [email-masked]
> 
> I'm assuming that the resolution was that the file was read before we
> finished writing it.  I've run into the same issue a number of times
> (interrupting and resuming Emacs builds leads to build failures, "make
> bootstrap" makes them go away).
> 
> Can we consider modifying the .elc format to have a footer indicating
> that the file is complete?

The .elc file is supposed to be created only when the compilation is
complete and successful.  If you look at byte-compile-file, you will
see that we first compile the Lisp code, then write the produced
bytecode to a temporary file, and only after that we rename the
temporary file into the target .elc file.  Renaming a file is an
atomic operation on Posix filesystems, so it either completely
succeeds or completely fails.

We only write directly to the target file if that file's directory is
unwritable.

So I don't understand why you see incomplete .elc files when you
interrupt the build.  What happens in my case is that I see those
temporary files left around, but I don't think I've ever saw an
incomplete .elc file after interrupting the build.

Is it likely that the directory where you build Emacs is not writable
by your user?  That's the only way I could explain what you see.  Or
maybe there's some other factor at work here, in which case we should
find out what that factor is, before we consider how to fix it.

In any case, I think this is a separate issue, so I'd prefer to have a
separate bug report for it.

Thanks.