public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/106190] [10/11/12/13 Regression] ICE in expand_builtin_eh_common with -fnon-call-exceptions -fsanitize=address,undefined -fno-sanitize-recover=all
Date: Mon, 27 Mar 2023 14:15:33 +0000	[thread overview]
Message-ID: <bug-106190-4-5xe8vuCCKw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106190-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106190

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
From what I can see, because of the -fsanitize-address-use-after-scope being on
by default, we end up with .ASAN_MARK (POISON, &d, 4); inside of a finally
block for try/finally, while previously we just had clobbers there.
This results in code like:
...
  finally_tmp.1 = 0;
  goto <D.3191>;
  <D.3191>:
  .ASAN_MARK (POISON, &d, 4);
  switch (finally_tmp.1) <default: <D.3194>, case 1: <D.3193>>
  <D.3194>:
  goto <D.3189>;
...
  <D.3192>:
  finally_tmp.1 = 1;
  goto <D.3191>;
  <D.3193>:
  resx 1
Where D.3192 is an EH landing pad.
This is because lower_try_finally decided not to copy the .ASAN_MARK (POISON,
&d, 4);
call when we aren't optimizing (it could happen also when optimizing if the
finally
block was large).
Next (perhaps something we could look at), in sanopt we see
  .UBSAN_BOUNDS (0B, 1, 1);
which is there on the
d[1][a] = 0;
statement first because it is an unconditional out of bound access given
d[1][...] declaration.  We actually emit
  if (1 >= 1)
    goto <bb 12>; [0.05%]
  else
    goto <bb 11>; [99.95%]
;;    succ:       11 [100.0% (guessed)]  (FALSE_VALUE)
;;                12 [0.0% (guessed)]  (TRUE_VALUE)

;;   basic block 12, loop depth 1, maybe hot
;;    prev block 3, next block 11, flags: (NEW)
;;    pred:       3 [0.0% (guessed)]  (TRUE_VALUE)
  __builtin___ubsan_handle_out_of_bounds_abort (&*.Lubsan_data0, 1);
;;    succ:       11 [always]  (FALLTHRU)

;;   basic block 11, loop depth 1, maybe hot
without folding the condition and having fallthrough edge even after the
noreturn call.

And later on during optimized pass we try to cleanup the cfg, see that the
d[1][a] = 0
statement is unreachable due to __builtin___ubsan_handle_out_of_bounds_abort
aborting unconditionally before that, so the EH block is unreachable and remove
that EH region.  But the code that uses __builtin_eh_pointer (1) looks to be
reachable (it is not, but nothing finds out that finally_tmp.1 is always 0. 
And we ICE trying to expand the
__builtin_eh_pointer (1) call.

  parent reply	other threads:[~2023-03-27 14:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 19:40 [Bug c/106190] New: [12/13 Regression] ICE in expand_builtin_eh_common, at except.cc:2084 gscfq@t-online.de
2022-07-04 20:13 ` [Bug middle-end/106190] " pinskia at gcc dot gnu.org
2022-07-04 22:17 ` pinskia at gcc dot gnu.org
2022-07-04 22:25 ` pinskia at gcc dot gnu.org
2022-07-04 22:25 ` [Bug middle-end/106190] [12/13 Regression] ICE in expand_builtin_eh_common with -fnon-call-exceptions -fsanitize=address,undefined -fno-sanitize-recover=all pinskia at gcc dot gnu.org
2022-07-05  7:58 ` rguenth at gcc dot gnu.org
2022-07-07 12:44 ` marxin at gcc dot gnu.org
2022-07-07 12:44 ` [Bug middle-end/106190] [9/10/11/12/13 " marxin at gcc dot gnu.org
2022-07-14 12:47 ` marxin at gcc dot gnu.org
2022-07-25 15:16 ` rguenth at gcc dot gnu.org
2022-07-25 15:16 ` [Bug middle-end/106190] [10/11/12/13 " rguenth at gcc dot gnu.org
2023-03-27 14:15 ` jakub at gcc dot gnu.org [this message]
2023-03-27 14:58 ` jakub at gcc dot gnu.org
2023-03-28  8:58 ` cvs-commit at gcc dot gnu.org
2023-03-28  9:17 ` [Bug middle-end/106190] [10/11/12 " jakub at gcc dot gnu.org
2023-04-18  7:16 ` cvs-commit at gcc dot gnu.org
2023-04-18  7:21 ` [Bug middle-end/106190] [10/11 " jakub at gcc dot gnu.org
2023-05-02 20:16 ` cvs-commit at gcc dot gnu.org
2023-05-03  9:26 ` [Bug middle-end/106190] [10 " jakub at gcc dot gnu.org
2023-05-03 15:23 ` cvs-commit at gcc dot gnu.org
2023-05-04  7:18 ` jakub at gcc dot gnu.org
2024-03-11  1:03 ` chenxiaolong at loongson dot cn

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=bug-106190-4-5xe8vuCCKw@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).