Subject: bug#70415: 30.0.50; [Cygwin] `lock-file' creates a symlink with funny name

From: Ken Brown <[email-masked]>
Date: Wed, 1 May 2024 17:20:20 -0400

On 4/30/2024 12:20 PM, Eli Zaretskii wrote:
>> Date: Tue, 30 Apr 2024 11:23:21 -0400
>> Cc: [email-masked], [email-masked]
>> From: Ken Brown <[email-masked]>
>>
>> On 4/29/2024 10:34 PM, Eli Zaretskii wrote:
>>>> Date: Mon, 29 Apr 2024 19:05:35 -0400
>>>> From: Ken Brown <[email-masked]>
>>>> Cc: [email-masked]
>>>>
>>>> I finally had a chance to look at this, and I can't reproduce the
>>>> problem.  The autosave file does not have the ":BOOT_TIME" part, and it
>>>> gets deleted properly when the file is saved.  I'm running the latest
>>>> stable release of Cygwin (3.5.3) on Windows 11 (version 23H2, build
>>>> 22631.3447).
>>>
>>> This is not about autosave files, this is about lock files.  Those are
>>> created once you modify a file-visiting buffer.
>>
>> Sorry, I didn't write what I meant.  I meant to refer to the lock file.
> 
> OK.  So it sounds like on some Cygwin systems this call in filelock.c:
> 
>    static int
>    lock_file_1 (Lisp_Object lfname, bool force)
>    {
>      intmax_t boot = get_boot_sec ();
> 
> yields a non-zero (and negative!) value of 'boot', and on other Cygwin
> systems it yields zero.  Because that's how Emacs decides whether to
> append that ":-NNNN" part:
> 
>      char const *lock_info_fmt = (boot
> 				 ? "%s@%s.%"PRIdMAX":%"PRIdMAX
> 				 : "%s@%s.%"PRIdMAX);
>      int len = snprintf (lock_info_str, sizeof lock_info_str,
> 			lock_info_fmt, user_name, host_name, pid, boot);
> 
> get_boot_sec calls get_boot_time, which is a Gnulib function (see
> lib/boot-time.c).  So I guess the key to unlock this puzzle is
> somewhere there.

I took a quick look at get_boot_time and found a bug, which may explain 
why some Cygwin systems behave differently from others.  I've reported 
it here:

   https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00008.html

Ken