Subject: bug#49261: 28.0.50; File Locking Breaks Presumptuous Toolchains

From: Eli Zaretskii <[email-masked]>
Date: Wed, 07 Jul 2021 22:20:50 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Wed, 07 Jul 2021 20:58:29 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Even if it currently works, it's unsafe, IMO, to not have any
> > protection there.  No one will remember that we rely on this not being
> > called early enough.
> 
> Right.  My reasoning was that it seemed unlikely to be a problem here,
> since the same function also (possibly) calls the Lisp functions
> userlock--ask-user-about-supersession-threat and ask-user-about-lock.
> But those are only called in some cases, so we're calling out to Lisp
> more now than before, and that may indeed be a problem.

Right, the call to userlock--ask-user-about-supersession-threat is
under some conditions that are rarely satisfied.

> I can add a check to whether the Lisp function is defined before calling
> (and then not do locking if it isn't) to be more defensive here?

I guess so.

> > So I'm asking whether the simplicity justifies the costs, here and
> > elsewhere.
> 
> I agree with you 100% that it's important to take this into
> consideration when moving things from C to Lisp.  In this particular
> case, I think the cost is justified, because this isn't a function
> that's called in a loop, and the other things it does (calling
> Fverify_visited_file_modtime and Ffile_exists_p, and actually creating
> the lock file) totally swamps any extra string consing, I think.  (That
> is, it won't take measurably longer.)

If it triggers GC, it _will_ take significantly longer.  But I won't
argue more about this, it's a lost battle anyway with current Emacs
development trends.