public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "iamanonymous.cs at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/112565] New: Abnormal Jump in Execution using 'stepi' Command in GDB under O2 optimization
Date: Thu, 16 Nov 2023 11:51:14 +0000	[thread overview]
Message-ID: <bug-112565-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 112565
           Summary: Abnormal Jump in Execution using 'stepi' Command in
                    GDB under O2 optimization
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---

Bug reported initially reported:
https://sourceware.org/bugzilla/show_bug.cgi?id=31070

Tom de Vries suggests that this issue may be attributed to a GCC optimization
bug.


$ cat small.c
int glob_int_arr[100];
int *glob_ptr_int = glob_int_arr;

void simple_global ()
{
  __builtin_prefetch (glob_int_arr, 0, 0);
  __builtin_prefetch (glob_ptr_int, 0, 0);
}

int main()
{
  simple_global ();
  exit (0);
}


$ gcc -w -O2 -g small.c; gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401040: file small.c, line 6.
(gdb) r
Starting program: /root/devil/a.out 

Breakpoint 1, main () at small.c:6
6         __builtin_prefetch (glob_int_arr, 0, 0);
(gdb) si
0x0000000000401044 in simple_global () at small.c:7
7         __builtin_prefetch (glob_ptr_int, 0, 0);
(gdb) si
0x000000000040104b in main () at small.c:13
13        exit (0);
(gdb) si
0x000000000040104d in simple_global () at small.c:6
6         __builtin_prefetch (glob_int_arr, 0, 0);
(gdb)


=================================================
When using the 'stepi' command in GDB, an abnormal jump in the execution occurs
when reaching line 7 of the code. The execution unexpectedly jumps to line 13.


$ gcc --version
gcc (GCC) 14.0.0 20231116 (experimental)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gdb --version
GNU gdb (GDB) 15.0.50.20231116-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

             reply	other threads:[~2023-11-16 11:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 11:51 iamanonymous.cs at gmail dot com [this message]
2023-11-16 11:55 ` [Bug debug/112565] " vries at gcc dot gnu.org
2023-11-16 12:00 ` iamanonymous.cs at gmail dot com
2023-11-16 12:42 ` iamanonymous.cs at gmail dot com
2023-11-16 12:47 ` rguenth at gcc dot gnu.org
2023-11-16 14:26 ` iamanonymous.cs at gmail dot com

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