Re: [PATCH 01/41] usage.c: move format processing out of die_errno()
- From
Jeff King <peff@peff.net>
- Date
- May 3, 2016, 10:15 UTC
- Message-ID
- <20160503101533.GA27522@sigill.intra.peff.net>
- In-Reply-To
- <CACsJy8DS5-dL8p8iMQs5B1++GaXNQWwdxUeaMCeZ12OoQcPO7Q@mail.gmail.com>
On Tue, May 03, 2016 at 04:39:45PM +0700, Duy Nguyen wrote:
Show 22 quoted lines
> On Tue, May 3, 2016 at 11:45 AM, Jeff King <peff@peff.net> wrote: > > On Mon, May 02, 2016 at 11:26:02AM -0700, Junio C Hamano wrote: > > > >> Caller supplied buffer would be the way to go when multiple threads > >> could be showing errors and warnings, right? > >> > >> It would not make too much of a difference for die(), though. > > > > I think it can matter for die(). This is happening above the pluggable > > die_routine() layer, so it's possible for an async task to call die() > > which will end in pthread_exit(), while the main program is calling > > die() to end in regular exit(). > > > > I imagine it's exceedingly unlikely, and of course both threads are > > dying anyway, but it could result in some pretty weird memory errors. > > It's probably worth taking precautions against, especially because it's > > to easy to do so. > > So, sum it up, the new fmt_with_err() will take a buffer and size. > die_errno() sticks to its static buffer as before. error_errno() and > warning_errno() can allocate 1k on stack to be more > multithread-friendly. Let me know if some other change is needed.
Yes, though note that die_errno() currently has a stack buffer, not a static one. It should remain that way (and error_errno and warning_errno should follow suit) to be friendly to multi-threading.
-Peff