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

From: "N. Jackson" <[email-masked]>
Date: Fri, 14 Feb 2025 14:02:55 +0000

At 18:01 +0000 on Monday 2025-02-10, Ihor Radchenko wrote:
>
> Very strange.
> How can it be if we do atomic writes?

I don't know enough of the details to be able to even begin to
answer that question.

Maybe(?) if insert-file-contents reads the file in chunks and if one
instance of Emacs runs org-persist--write-elisp-file at the same
time as the other instance if running org-persist--read-elisp-file,
perhaps the file could be replaced in the middle of the read.  Then
maybe chunks could be read in from both the old and the new files?

> 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

I have applied your diff and will report back with details when I
next get the warning.