From: Jakub Jelinek <jakub@redhat.com>
To: Marek Polacek <polacek@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>,
Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v2] docs: Suggest options to improve ASAN stack traces
Date: Thu, 8 Dec 2022 16:00:15 +0100 [thread overview]
Message-ID: <Y5H7/78c23RkIaT9@tucnak> (raw)
In-Reply-To: <Y5H1+kCo+hcQsDHU@redhat.com>
On Thu, Dec 08, 2022 at 09:34:34AM -0500, Marek Polacek wrote:
> I got a complaint that while Clang docs suggest options that improve
> the quality of the backtraces ASAN prints (cf.
> <https://clang.llvm.org/docs/AddressSanitizer.html#usage>), our docs
> don't say anything to that effect. This patch amends that with a new
> paragraph. (It deliberately doesn't mention -fno-omit-frame-pointer.)
>
> gcc/ChangeLog:
>
> * doc/invoke.texi (-fsanitize=address): Suggest options to improve
> stack traces.
> ---
> gcc/doc/invoke.texi | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 726392409b6..1641efecf18 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -16510,6 +16510,15 @@ The option cannot be combined with @option{-fsanitize=thread} or
> @option{-fsanitize=hwaddress}. Note that the only target
> @option{-fsanitize=hwaddress} is currently supported on is AArch64.
>
> +To get more accurate stack traces, it is possible to use options such as
> +@option{-O} (which, for instance, prevents most function inlining),
Still not sure about this part. For one, I wonder if we shouldn't
recommend -O0, -O1 or -Og instead of just one of them, and I'm also not sure
how much function inlining is prevented with -O1.
always_inline functions are certainly inlined even at -O0 or -Og (at least
when called directly), -O1 adds
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_finline_functions_called_once, NULL, 1 },
to that, -O2 adds
{ OPT_LEVELS_2_PLUS, OPT_findirect_inlining, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_finline_small_functions, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fpartial_inlining, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_finline_functions, NULL, 1 },
and -O3 further bumps some parameters:
{ OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_auto_, NULL, 30 },
{ OPT_LEVELS_3_PLUS, OPT__param_early_inlining_insns_, NULL, 14 },
{ OPT_LEVELS_3_PLUS, OPT__param_inline_heuristics_hint_percent_, NULL, 600 },
{ OPT_LEVELS_3_PLUS, OPT__param_inline_min_speedup_, NULL, 15 },
{ OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_single_, NULL, 200 },
> +@option{-fno-optimize-sibling-calls} (which prevents optimizing sibling
-fno-optimize-sibling-calls is the default for -O0/-O1/-Og; dunno if we
want to reiterate it.
> +and tail recursive calls), or @option{-fno-ipa-icf} (which disables Identical
> +Code Folding for functions). Since multiple runs of the program may yield
> +backtraces with different addresses due to ASLR (Address Space Layout
> +Randomization), it may be desirable to turn ASLR off. On Linux, this can be
> +achieved with @samp{setarch `uname -m` -R ./prog}.
> +
> @item -fsanitize=kernel-address
> @opindex fsanitize=kernel-address
> Enable AddressSanitizer for Linux kernel.
Jakub
next prev parent reply other threads:[~2022-12-08 15:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-07 20:34 [PATCH] " Marek Polacek
2022-12-08 7:25 ` Florian Weimer
2022-12-08 14:11 ` Marek Polacek
2022-12-08 14:28 ` Jakub Jelinek
2022-12-08 14:34 ` [PATCH v2] " Marek Polacek
2022-12-08 15:00 ` Jakub Jelinek [this message]
2022-12-08 22:56 ` [PATCH v3] " Marek Polacek
2022-12-08 23:11 ` Jakub Jelinek
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=Y5H7/78c23RkIaT9@tucnak \
--to=jakub@redhat.com \
--cc=fweimer@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=polacek@redhat.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 read-only IMAP folder(s) and NNTP newsgroup(s).