From: Martin Ågren Date: Sun, 06 May 2018 15:56:31 GMT Subject: Re: [PATCH 2/5] refs.c: do not die if locking fails in `write_pseudoref()` Message-ID: In-Reply-To: <1525621731.16035.11.camel@novalis.org> On 6 May 2018 at 17:48, David Turner wrote: > On Sun, 2018-05-06 at 16:10 +0200, Martin Ågren wrote: >> While at it, make the lock non-static. > Re making the lock static, I wonder about the following case: > > if (read_ref(pseudoref, &actual_old_oid)) > > die("could not read ref '%s'", pseudoref); > > I think this calls exit(), and then atexit tries to clean up the lock > files. But since lock is no longer static, the stack may have been > destroyed (I don't actually know whether this is true, so maybe someone > else does). Right. After commit 076aa2cbda (tempfile: auto-allocate tempfiles on heap, 2017-09-05) this is safe though. Quite a few locks have already been moved to the stack, e.g., in 14bca6c63c (sequencer: make lockfiles non-static, 2018-02-27) and 02ae242fdd (checkout-index: simplify locking logic, 2017-10-05). I could add a note to the commit message to make this clear, like "After 076aa2cbda, locks no longer need to be static." Martin