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 c++/61597] Unexpected behavior at runtime
Date: Tue, 31 Jan 2023 03:35:56 +0000	[thread overview]
Message-ID: <bug-61597-4-ATDNI1c8fU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-61597-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #21 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The trunk can detect this with the reduced testcase in comment #16 with
-fsanitize=address (it could not in GCC 12 though):

=================================================================
==1==ERROR: AddressSanitizer: stack-use-after-return on address 0x7fed23a00020
at pc 0x000000401410 bp 0x7ffd3ef98df0 sp 0x7ffd3ef98de8
READ of size 4 at 0x7fed23a00020 thread T0
    #0 0x40140f in main /app/example.cpp:18
    #1 0x7fed26088082 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId:
1878e6b475720c7c51969e69ab2d276fae6d1dee)
    #2 0x4010ed in _start (/app/output.s+0x4010ed) (BuildId:
eae82a9845e6e2c7baecc615e9a9cf9fe73eac81)

Address 0x7fed23a00020 is located in stack of thread T0 at offset 32 in frame
    #0 0x4011b5 in func(Iter, int) /app/example.cpp:11

  This frame has 1 object(s):
    [32, 36) 'iter' (line 11) <== Memory access at offset 32 is inside this
variable
HINT: this may be a false positive if your program uses some custom stack
unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-use-after-return /app/example.cpp:18 in main
Shadow bytes around the buggy address:
  0x7fed239ffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fed239ffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fed239ffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fed239fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fed239fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x7fed23a00000: f5 f5 f5 f5[f5]f5 f5 f5 00 00 00 00 00 00 00 00
  0x7fed23a00080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fed23a00100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fed23a00180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fed23a00200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fed23a00280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==1==ABORTING

      parent reply	other threads:[~2023-01-31  3:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24 17:18 [Bug c++/61597] New: " adrien.hamelin+gcc at gmail dot com
2014-06-24 18:00 ` [Bug c++/61597] " adrien.hamelin+gcc at gmail dot com
2014-06-25  6:47 ` adrien.hamelin+gcc at gmail dot com
2014-06-25  6:57 ` trippels at gcc dot gnu.org
2014-06-25  8:22 ` adrien.hamelin+gcc at gmail dot com
2014-06-25  8:36 ` adrien.hamelin+gcc at gmail dot com
2014-06-25 10:03 ` redi at gcc dot gnu.org
2014-06-25 10:12 ` redi at gcc dot gnu.org
2014-06-25 11:30 ` adrien.hamelin+gcc at gmail dot com
2014-06-25 12:16 ` redi at gcc dot gnu.org
2014-06-25 13:00 ` glisse at gcc dot gnu.org
2014-06-25 13:08 ` redi at gcc dot gnu.org
2014-06-25 13:23 ` glisse at gcc dot gnu.org
2014-06-25 16:56 ` manu at gcc dot gnu.org
2014-06-25 20:31 ` glisse at gcc dot gnu.org
2023-01-31  3:35 ` pinskia at gcc dot gnu.org [this message]

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