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

From: Ihor Radchenko <[email-masked]>
Date: Mon, 10 Feb 2025 18:01:10 +0000

"N. Jackson" <[email-masked]> writes:

>> This is strange. Was it still "end of file while reading"?
>
> No.  Yes, it was exactly the same error message, but the actual
> message is this:
>
>   Warning (emacs): Emacs reader failed to read data in
>   "/home/nlj/.cache/org-persist/gc-lock.eld". The error was: "End of
>   file during parsing"
>
> It comes from the error handler for the condition-case in
> org-persist--read-elisp-file.
>
> (To be absolutely clear, the changes I applied to my Emacs are the
> ones I showed in my earlier post[1].  This only applies the atomic
> write part of your patches, not the "write index before writing
> cache data" part (which I didn't see how to easily integrate into
> the org-persist.el in Emacs 30).)

Very strange.
How can it be if we do atomic writes?

Maybe try to install the attached diff that will also display the
contents of the file as an additional warning.
Maybe it can give us more clues.

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index a639699d93..58facc0b30 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -449,7 +449,9 @@ (defun org-persist--read-elisp-file (&optional buffer-or-file)
              (message "Emacs reader failed to read data in %S. The error was: %S"
                       buffer-or-file (error-message-string err))
            (warn "Emacs reader failed to read data in %S. The error was: %S"
-                 buffer-or-file (error-message-string err)))
+                 buffer-or-file (error-message-string err))
+           (warn "The problematic file contents is:\n-----\n%s\n------\n"
+                 (buffer-string)))
          nil)))))
 
 ;; FIXME: `pp' is very slow when writing even moderately large datasets

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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>