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

Re: glibc mutex deadlock in signal handler

From
Jeff King <peff@peff.net>
Date
Sep 4, 2015, 13:04 UTC
Message-ID
<20150904130448.GB25501@sigill.intra.peff.net>
In-Reply-To
<s5hzj12jzlu.wl-tiwai@suse.de>
On Fri, Sep 04, 2015 at 11:35:57AM +0200, Takashi Iwai wrote:
Show 6 quoted lines
> > Hmm, is there is any reason to just pass an "in_signal" flag to
> > wait_for_pager(), to avoid duplicating the logic?
> 
> Just because wait_for_pager() itself is an atexit hook that can't take
> an argument, so we'd need to split to a new function.  I don't mind
> either way.  The revised patch is below.

Ah, right. That's unfortunate, but I think I prefer adding the extra wrapper to duplicating the contents of the function.

> -- 8< --
> From: Takashi Iwai <tiwai@suse.de>
> Subject: [PATCH v2] pager: don't use unsafe functions in signal handlers
> [...]

This looks good to me. Do you plan on fixing any of the other handlers (you don't have to; I just want to know if somebody is planning to work on it).

The pattern of atexit and signal handlers is repeated in several places, and it seems like we will have to add the same in_signal boilerplate in each instance. I wonder if we should provide a global "register_cleanup" that takes a "void (*func)(int in_signal))" function pointer, and:

  1. Adds it to a list (ideally in a way that is atomic if we get
     interrupted while adding to the list).
  2. If not already run, registers an atexit() handler and
     sigchain_push_common for a meta-handler which runs through the list
     and runs each handler.

It's not a _huge_ amount of boilerplate code we'd be saving, but at least conforming to the "in_signal" function template would make people think twice about what they're doing inside the cleanup function. :)

-Peff
Previous: Takashi IwaiNext: Takashi Iwai
Message 8 of 11 in “glibc mutex deadlock in signal handler”
  1. Takashi IwaiSep 3, 2015
  2. Junio C HamanoSep 3, 2015
  3. Takashi IwaiSep 3, 2015
  4. Andreas SchwabSep 3, 2015
  5. Takashi IwaiSep 4, 2015
  6. Jeff KingSep 4, 2015
  7. Takashi IwaiSep 4, 2015
  8. Jeff KingSep 4, 2015
  9. Takashi IwaiSep 4, 2015
  10. Junio C HamanoSep 4, 2015
  11. Jeff KingSep 5, 2015

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.