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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes even clang says this is undefined.

ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 1
=================================================================
==1==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7bc9be3f0060
at pc 0x5b1595e4cf6c bp 0x7ffc088c70d0 sp 0x7ffc088c70c8
READ of size 4 at 0x7bc9be3f0060 thread T0
    #0 0x5b1595e4cf6b in my_coro(int, int&, int&&) (.resume)
/app/example.cpp:178:22
    #1 0x5b1595e4e6d3 in
std::__1::coroutine_handle<coro1::promise_type>::resume[abi:nqe230000]() const
/cefs/a0/a0eac97a78a7814c1d665790_clang-trunk-20260317/bin/../include/c++/v1/__coroutine/coroutine_handle.h:144:5
    #2 0x5b1595e4ca2d in main /app/example.cpp:193:12
    #3 0x7fc9c0429d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId:
095c7ba148aeca81668091f718047078d57efddb)
    #4 0x7fc9c0429e3f in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) (BuildId:
095c7ba148aeca81668091f718047078d57efddb)
    #5 0x5b1595d65394 in _start (/app/output.s+0x2d394)

Address 0x7bc9be3f0060 is located in stack of thread T0 at offset 96 in frame
    #0 0x5b1595e4c88f in main /app/example.cpp:183

  This frame has 4 object(s):
    [32, 36) 'lvr' (line 186)
    [48, 52) 'ref.tmp' (line 187)
    [64, 72) 'x' (line 188)
    [96, 100) 'ref.tmp' (line 188) <== Memory access at offset 96 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-scope /app/example.cpp:178:22 in
my_coro(int, int&, int&&) (.resume)
Shadow bytes around the buggy address:
  0x7bc9be3efd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc9be3efe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc9be3efe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc9be3eff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc9be3eff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x7bc9be3f0000: f1 f1 f1 f1 04 f2 04 f2 00 f2 f2 f2[f8]f3 f3 f3
  0x7bc9be3f0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc9be3f0100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc9be3f0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc9be3f0200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc9be3f0280: 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

Reply via email to