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

            Bug ID: 91328
           Summary: stack-use-after-scope for in-class initialization of
                    std::vector<int> member using initializer_list
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: geert.fan...@auro-technologies.com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

Created attachment 46663
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46663&action=edit
Preprocessed source file

GCC and system details (`gcc -v`):
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-lto --enable-plugin --enable-install-libiberty
--with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib
--disable-werror --enable-checking=release --enable-default-pie
--enable-default-ssp --enable-cet=auto
Thread model: posix
gcc version 9.1.0 (GCC) 

Compiler statement: `g++ test.ii -fsanitize=address -O3 -Wall -Wextra`
 => no warnings

Running application: `./a.out`
 => ASAN stack-use-after-scope error
=================================================================
==1669==ERROR: AddressSanitizer: stack-use-after-scope on address
0x562395364060 at pc 0x7eff4508aab4 bp 0x7ffd220dfa40 sp 0x7ffd220df1e8
READ of size 12 at 0x562395364060 thread T0
    #0 0x7eff4508aab3 in __interceptor_memcpy
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:790
    #1 0x56239536343b in f()
(/home/geertf/tmp/repro-bug-gcc9-asan/a.out+0x143b)
    #2 0x56239536317d in main
(/home/geertf/tmp/repro-bug-gcc9-asan/a.out+0x117d)
    #3 0x7eff44b09ee2 in __libc_start_main (/usr/lib/libc.so.6+0x26ee2)
    #4 0x5623953631ed in _start
(/home/geertf/tmp/repro-bug-gcc9-asan/a.out+0x11ed)

0x562395364060 is located 0 bytes inside of global variable 'C.0' defined in
'test.cpp:3:8' (0x562395364060) of size 12
SUMMARY: AddressSanitizer: stack-use-after-scope
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:790
in __interceptor_memcpy
Shadow bytes around the buggy address:
  0x0ac4f2a647b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac4f2a647c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac4f2a647d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac4f2a647e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac4f2a647f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ac4f2a64800: 00 00 00 00 00 00 00 00 00 00 00 00[f8]f8 f9 f9
  0x0ac4f2a64810: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac4f2a64820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac4f2a64830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac4f2a64840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac4f2a64850: 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
  Shadow gap:              cc
==1669==ABORTING

The original source code for this bug can be found here:
https://github.com/gfannes/repro-bug-gcc9-asan

Reply via email to