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
Junio C Hamano <gitster@pobox.com>
Date
Sep 27, 2022, 16:50 UTC
Message-ID
<xmqqedvw7od9.fsf@gitster.g>
In-Reply-To
<YzLiI1HZeBszsIJq@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> So all of that makes me think we should not add a new flag here, but
> instead just avoid calling the function entirely from
> tmp_objdir_destroy_1().

Thanks. I missed that undefined access to errno that breaks the intention of the patch.

Show 24 quoted lines
> But then we can observe that tmp_objdir_destroy_1() is basically doing
> nothing if on_signal is set. So there is really no point in setting up
> the signal handler at all. We should just set up the atexit() handler.
> I.e., something like:
>
> diff --git a/tmp-objdir.c b/tmp-objdir.c
> index a8be92bca1..10549e95db 100644
> --- a/tmp-objdir.c
> +++ b/tmp-objdir.c
> @@ -169,7 +169,6 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix)
>  	the_tmp_objdir = t;
>  	if (!installed_handlers) {
>  		atexit(remove_tmp_objdir);
> -		sigchain_push_common(remove_tmp_objdir_on_signal);
>  		installed_handlers++;
>  	}
>  
>
> with the commit message explaining that we can't do the cleanup in a
> portable and signal-safe way, so we just punt on the whole concept.
>
> There's also some minor cleanup we could do elsewhere to drop the
> "on_signal" argument (which can come as part of the same patch, or on
> top).
;-)  I like the simplification.
Previous: Jeff KingNext: John Cai via GitGitGadget
Message 9 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.