From: Ingo Molnar <mingo@elte.hu>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Peter Seebach <peter.seebach@windriver.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Anton Blanchard <anton@samba.org>,
paulus@samba.org, dsahern@gmail.com, fweisbec@gmail.com,
yanmin_zhang@linux.intel.com, emunson@mgebm.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf: Incorrect use of snprintf results in SEGV
Date: Thu, 8 Mar 2012 08:34:54 +0100 [thread overview]
Message-ID: <20120308073454.GD20784@elte.hu> (raw)
In-Reply-To: <1331153964.11248.362.camel@twins>
* Peter Zijlstra <peterz@infradead.org> wrote:
> On Wed, 2012-03-07 at 21:37 +0100, Ingo Molnar wrote:
> > size_needed = snprintf_size(...);
>
> This would require 3 passes over the fmt+args, first to find
> the allocated size is insufficient, 2nd to compute the size,
> 3rd to fill buffer.
No. The 1% case would use this separate API with its quirky
return value. snprintf_size() works like today's snprintf, it's
just *named* clearly to signal that it returns something not
quite intuitive and results in bugs even in code that *tries* to
be aware of the corner cases.
> Whereas with the current "creative" API only 2 passes are
> needed.
>
> I can imagine that back in the day of small memory and small
> CPU this was deemed important enough.
>
> Anyway, its all moot, this API exists and has been out in the
> wild for several decades now, its not like we can actually
> change it :-)
Of course it is moot - I am not arguing for a change in the API.
But the self-justification, as outlined in the mail I replied
to, is brutally wrong, and nowhere in this discussion did I see
the important notion mentioned that the *common case matters* -
so maybe reading this will keep others from committing the same
mistake, with newly introduced APIs.
Thanks,
Ingo
next prev parent reply other threads:[~2012-03-08 7:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 0:42 [PATCH] perf: Incorrect use of snprintf results in SEGV Anton Blanchard
2012-03-07 0:49 ` Peter Seebach
2012-03-07 1:09 ` Arnaldo Carvalho de Melo
2012-03-07 1:29 ` Peter Seebach
2012-03-07 18:44 ` Nick Bowler
2012-03-07 20:24 ` Peter Seebach
2012-03-07 20:37 ` Ingo Molnar
2012-03-07 20:59 ` Peter Zijlstra
2012-03-07 21:28 ` Peter Seebach
2012-03-08 7:34 ` Ingo Molnar [this message]
2012-03-08 8:51 ` Peter Seebach
2012-03-07 21:19 ` Peter Seebach
2012-03-08 0:58 ` Arnaldo Carvalho de Melo
2012-03-08 7:48 ` Ingo Molnar
2012-03-08 7:52 ` Ingo Molnar
2012-03-09 19:00 ` Peter Seebach
2012-03-14 19:59 ` [tip:perf/urgent] perf tools: " tip-bot for Anton Blanchard
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=20120308073454.GD20784@elte.hu \
--to=mingo@elte.hu \
--cc=acme@redhat.com \
--cc=anton@samba.org \
--cc=dsahern@gmail.com \
--cc=emunson@mgebm.net \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=peter.seebach@windriver.com \
--cc=peterz@infradead.org \
--cc=yanmin_zhang@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.