Subject: Re: bug#78712: 31.0.50; definition is void in file-notify

From: Al Haji-Ali <[email-masked]>
Date: Mon, 09 Jun 2025 09:31:03 +0100

On 06/06/2025, Michael Albinus wrote:
> Well, let's analyze what happens. No artificial test code.

Happy to help with this. Just a couple of notes:
- If the "error" is the bizarre action sequence, while it is regularly re-produced, I don't know the precise conditions for it so I will have to wait until it randomly shows up for any debugging.
- If the action sequence (rename attrib delete) is an expected one, my "artificial" code is just showing that this sequence causes the error to be thrown due to the logic in the code.

> Please set file-notify-debug. We'll see the arrived events then in the
> *Message* buffer, like shown in my other message:
>
> --8<---------------cut here---------------start------------->8---
> file-notify-handle-event (file-notify (6 (rename) "xxx" "yyy") file-notify--callback-kqueue)
> --8<---------------cut here---------------end--------------->8---
>
> Send the event traces.

I got this.

--8<---------------cut here---------------start------------->8---
file-notify-handle-event (file-notify (61 (rename attrib delete) "[redacted-dir]/[redacted-filename]") file-notify--callback-kqueue)
file-notify-callback 61 deleted "[redacted-dir]/[redacted-filename]" nil #s(file-notify--watch "[redacted-dir]" "[redacted-filename]" auto-revert-notify-handler) "[redacted-dir]/[redacted-filename]" "[redacted-dir]"
file-notify-handle-event (file-notify (61 stopped "[redacted-dir]/[redacted-filename]") auto-revert-notify-handler) [2 times]
file-notify-callback 61 attribute-changed "[redacted-dir]/[redacted-filename]" nil #s(file-notify--watch "[redacted-dir]" "[redacted-filename]" nil) "[redacted-dir]/[redacted-filename]" "[redacted-dir]"
file-notify--call-handler: Symbol’s function definition is void: nil
--8<---------------cut here---------------end--------------->8---

Note that while I tested my artificial code on 31.0.50, showing the error being thrown, the log above is reported from my daily Emacs 29.1.
For various reasons I cannot update to the latest version for my daily Emacs and as I mentioned the error happens somewhat randomly, so my only real chance to catch it is in this emacsen. 

> I'd like also to understand what has triggered the (rename attrib
> delete) actions combined in one event. Is it related to an edit action
> from yourself, or due to the said sync action? Which kind of sync action
> is this?
I suspect it is triggered by an action of my automatic sync. This is an iCloud driver on macOS.
I've also seen similar errors on a file in a Dropbox folder (again on macOS).

> Does the sync action happen on a mounted file system?
Yes, the file system should be mounted, I believe. Though I am unclear on the internals of an iCloud drive.