From: Jeff King <peff@peff.net>
To: Stefan Beller <sbeller@google.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH] usage: try harder to format very long error messages
Date: Tue, 11 Aug 2015 12:33:55 -0400 [thread overview]
Message-ID: <20150811163355.GA15521@sigill.intra.peff.net> (raw)
In-Reply-To: <CAGZ79kbL6DuXoQi72z_5=PZy2+HPh_L4+FJ_diokJi6s3uP57g@mail.gmail.com>
On Tue, Aug 11, 2015 at 09:28:34AM -0700, Stefan Beller wrote:
> On Tue, Aug 11, 2015 at 9:17 AM, Jeff King <peff@peff.net> wrote:
> > We use a fixed-size buffer of 4096 bytes to format die() and
> > error() messages. We explicitly avoided using a strbuf or
> > other fanciness here, because we want to make sure that we
> > report the message even in the face of malloc() failure
> > (after all, we might even be dying due to a malloc call).
>
> Would it make sense to allocate memory in the early startup phase
> for a possible error message?
> So instead of putting 4kb on the stack we'd just have an unused 16kb
> on the heap.
Isn't that just punting on the problem? Now your 16kb filename will get
truncated messages (in general we cannot even work with such files, but
it is nice if the error message telling us so is readable).
If stack space is the problem, we can just put 16kb in BSS. But I think
we really do want something that grows to the appropriate size. Or we
need to start being more clever about our truncation. E.g., printing:
error: unable to stat 'aaaaaaaaa[...]aaaaaa/foo': File too long
where the "[...]" is literally what we would print. The trouble with
that approach is that it is hard to intercept large strings without
re-implementing all of stdio's formatting.
-Peff
next prev parent reply other threads:[~2015-08-11 16:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 16:17 [PATCH] usage: try harder to format very long error messages Jeff King
2015-08-11 16:28 ` Stefan Beller
2015-08-11 16:33 ` Jeff King [this message]
2015-08-11 16:34 ` Junio C Hamano
2015-08-11 18:05 ` Jeff King
2015-08-11 18:06 ` [PATCH 1/2] vreportf: report to arbitrary filehandles Jeff King
2015-08-11 18:13 ` [PATCH 2/2] vreportf: avoid intermediate buffer Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150811163355.GA15521@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).