public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/107769] [12/13 Regression] -flto with -Os/-O2/-O3 emitted code with gcc 12.x segfaults via mutated global in .rodata
Date: Sun, 20 Nov 2022 18:23:30 +0000	[thread overview]
Message-ID: <bug-107769-4-ulNfpbG3pi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107769-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|-flto with -Os/-O2/-O3      |[12/13 Regression] -flto
                   |emitted code with gcc 12.x  |with -Os/-O2/-O3 emitted
                   |segfaults via mutated       |code with gcc 12.x
                   |global in .rodata           |segfaults via mutated
                   |                            |global in .rodata
     Ever confirmed|0                           |1
      Known to fail|                            |12.1.0, 13.0
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |12.3
   Last reconfirmed|                            |2022-11-20
      Known to work|                            |11.1.0

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, reduced further, removing malloc and changing srand into a function
inside the TU (with noipa attribute):
[[gnu::noipa]]
void hjj (unsigned int lk)
{
    (void)lk;
}
void nn(int i, int n);
[[gnu::noinline]]
int ll(void) {
    return 1;
}
void hh(int* dest, int src)
{
    if (!ll() && !src)
        hjj(100);
    (*dest) = 1;
}
void gg(int* result, int x)
{
    if (x >= 0)
        return;

    int xx;
    xx = *result;
    hh(result, ll());
    if (xx >= *result)
        nn(xx, *result);
}
void nn(int i, int n) {
    int T8_;
    if (n < 0)
        __builtin_exit(0);
    T8_ = 0;
    gg(&T8_, i);
    __builtin_exit(0);
}
void kk(int* x, int i) {
    hh(x, ll());
    if (i < 0 || i >= *x)
        nn(i,*x);
}
int g__r_1 = 0;
int main() {
    kk(&g__r_1, 0);
    return 0;
}

  reply	other threads:[~2022-11-20 18:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20 15:54 [Bug c/107769] New: " resence at parsoma dot net
2022-11-20 18:23 ` pinskia at gcc dot gnu.org [this message]
2022-11-21  8:45 ` [Bug ipa/107769] [12/13 Regression] -flto with -Os/-O2/-O3 emitted code with gcc 12.x segfaults via mutated global in .rodata since r12-2887-ga6da2cddcf0e959d marxin at gcc dot gnu.org
2022-11-21 10:29 ` hubicka at gcc dot gnu.org
2022-11-22  8:33 ` rguenth at gcc dot gnu.org
2023-03-24 13:51 ` jamborm at gcc dot gnu.org
2023-03-30  3:35 ` yinyuefengyi at gmail dot com
2023-03-31 11:09 ` jamborm at gcc dot gnu.org
2023-04-06 17:01 ` jamborm at gcc dot gnu.org
2023-04-17 11:06 ` cvs-commit at gcc dot gnu.org
2023-04-17 14:17 ` [Bug ipa/107769] [12 " jamborm at gcc dot gnu.org
2023-04-26 16:45 ` cvs-commit at gcc dot gnu.org
2023-04-26 16:46 ` jamborm at gcc dot gnu.org

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-107769-4-ulNfpbG3pi@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).