git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/5] refs.c: do not die if locking fails in `write_pseudoref()`

From
David Turner <novalis@novalis.org>
Date
May 7, 2018, 11:12 UTC
Message-ID
<01AF002E-C9E2-48FB-97AB-D9D903866310@novalis.org>
In-Reply-To
<CAN0heSpfu+070fxhjjccXQpfFnr13O4tvSaj44YWkFWVJL_4mA@mail.gmail.com>
On May 6, 2018 9:56:31 AM MDT, "Martin Ågren" <martin.agren@gmail.com> wrote:
Show 23 quoted lines
>On 6 May 2018 at 17:48, David Turner <novalis@novalis.org> 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."
I am going to reply now to keep the thread moving, but I am on my phone with bad connectivity (few cell towers in Bears Ears), so I can't really check the code. Feel free to disregard if I am still wrong.
I saw that patch, but I thought the new logic required that cleanup funtions be called before the lock goes out of scope.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Previous: Martin ÅgrenNext: Jeff King
Message 4 of 6 in “refs.c: do not die if locking fails in `write_pseudoref()`”
  1. 2/5 refs.c: do not die if locking fails in `write_pseudoref()`Martin Ågren, May 6, 2018
  2. David TurnerMay 6, 2018
  3. Martin ÅgrenMay 6, 2018
  4. David TurnerMay 7, 2018
  5. Jeff KingMay 8, 2018
  6. Stefan BellerMay 7, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.