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

Re: [PATCH] tmp-objdir: do not opendir() when handling a signal

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Sep 27, 2022, 09:18 UTC
Message-ID
<99c45b89-364f-4f77-7c1b-26231cc7455e@dunelm.org.uk>
In-Reply-To
<pull.1348.git.git.1664236383785.gitgitgadget@gmail.com>
Hi John
On 27/09/2022 00:53, John Cai via GitGitGadget wrote:
Show 10 quoted lines
> From: John Cai <johncai86@gmail.com>
> 
> In the tmp-objdir api, tmp_objdir_create will create a temporary
> directory but also register signal handlers responsible for removing
> the directory's contents and the directory itself. However, the
> function responsible for recursively removing the contents and
> directory, remove_dir_recurse() calls opendir(3) and closedir(3).
> This can be problematic because these functions allocate and free
> memory, which are not async-signal-safe functions. This can lead to
> deadlocks.
Show 8 quoted lines
> --- a/dir.h
> +++ b/dir.h
> @@ -498,6 +498,9 @@ int get_sparse_checkout_patterns(struct pattern_list *pl);
>   /* Remove the_original_cwd too */
>   #define REMOVE_DIR_PURGE_ORIGINAL_CWD 0x08
>   
> +/* Indicates a signal is being handled */
> +#define REMOVE_DIR_SIGNAL 0x16

This is setting the bits for REMOVE_DIR_KEEP_NESTED_GIT and REMOVE_DIR_KEEP_TOPLEVEL is that intentional? (it looks like you've doubled 8 to 16 to get the next free bit but used a hex constant, the earlier constants use decimal)

Best Wishes
Phillip
Previous: Junio C HamanoNext: Jeff King
Message 5 of 18 in “tmp-objdir: do not opendir() when handling a signal”
  1. tmp-objdir: do not opendir() when handling a signalJohn Cai via GitGitGadget, Sep 26, 2022
  2. Taylor BlauSep 27, 2022
  3. Jeff KingSep 27, 2022
  4. Junio C HamanoSep 27, 2022
  5. Phillip WoodSep 27, 2022
  6. Jeff KingSep 27, 2022
  7. John CaiSep 27, 2022
  8. Jeff KingSep 27, 2022
  9. Junio C HamanoSep 27, 2022
  10. tmp-objdir: skip clean up when handling a signalJohn Cai via GitGitGadget, Sep 27, 2022
  11. Jeff KingSep 27, 2022
  12. Jeff KingSep 27, 2022
  13. tmp-objdir: skip clean up when handling a signalJohn Cai via GitGitGadget, Sep 28, 2022
  14. Ævar Arnfjörð BjarmasonSep 28, 2022
  15. tmp-objdir: skip clean up when handling a signalJohn Cai via GitGitGadget, Sep 30, 2022
  16. Jeff KingOct 3, 2022
  17. Another possible instance of async-signal-safe opendir path callstack? (Was: [PATCH] tmp-objdir: do not opendir() when handling a signal)Jan Pokorný, Oct 20, 2022
  18. Jeff KingOct 20, 2022

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.