This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug testsuite/63297] New: ASan reported heap-use-after-free in g++.old-deja/g++.law/virtual3.C.


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

            Bug ID: 63297
           Summary: ASan reported heap-use-after-free in
                    g++.old-deja/g++.law/virtual3.C.
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chefmax at gcc dot gnu.org
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 33512
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33512&action=edit
This trivial patch seems to fix the issue.

ASan reported heap-use-after-free in g++.old-deja/g++.law/virtual3.C:

$ ~/install/master/bin/g++ gcc/testsuite/g++.old-deja/g++.law/virtual3.C
-fsanitize=address

$ ./a.out

=================================================================
==26271==ERROR: AddressSanitizer: heap-use-after-free on address 0x60300000eff8
at pc 0x7fd84fbb6470 bp 0x7fff4d8204a0 sp 0x7fff4d81fc60
READ of size 5 at 0x60300000eff8 thread T0
    #0 0x7fd84fbb646f in __interceptor_strlen
/home/max/workspace/downloads/gcc/libsanitizer/asan/asan_interceptors.cc:536
    #1 0x7fd84f8ed2d8 in std::char_traits<char>::length(char const*)
/home/max/build/master-x86_64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:263
    #2 0x7fd84f8ed2d8 in std::basic_ostream<char, std::char_traits<char> >&
std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)
/home/max/build/master-x86_64/x86_64-unknown-linux-gnu/libstdc++-v3/include/ostream:536
    #3 0x401515 in BugStream::eval()
(/home/max/workspace/downloads/gcc/a.out+0x401515)
    #4 0x4015ef in operator<<(std::ostream&, Eval_)
(/home/max/workspace/downloads/gcc/a.out+0x4015ef)
    #5 0x401699 in main (/home/max/workspace/downloads/gcc/a.out+0x401699)
    #6 0x7fd84efa576c in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x2176c)
    #7 0x4013c8 (/home/max/workspace/downloads/gcc/a.out+0x4013c8)

0x60300000eff8 is located 24 bytes inside of 30-byte region
[0x60300000efe0,0x60300000effe)
freed by thread T0 here:
    #0 0x7fd84fbf36a9 in operator delete(void*)
/home/max/workspace/downloads/gcc/libsanitizer/asan/asan_new_delete.cc:85
    #1 0x7fd84f914eef in std::string::_Rep::_M_dispose(std::allocator<char>
const&)
/home/max/build/master-x86_64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:249
    #2 0x7fd84f914eef in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string()
/home/max/build/master-x86_64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:547
    #3 0x4015ef in operator<<(std::ostream&, Eval_)
(/home/max/workspace/downloads/gcc/a.out+0x4015ef)
    #4 0x401699 in main (/home/max/workspace/downloads/gcc/a.out+0x401699)
    #5 0x7fd84efa576c in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x2176c)

previously allocated by thread T0 here:
    #0 0x7fd84fbf3169 in operator new(unsigned long)
/home/max/workspace/downloads/gcc/libsanitizer/asan/asan_new_delete.cc:53
    #1 0x7fd84f914d18 in __gnu_cxx::new_allocator<char>::allocate(unsigned
long, void const*)
/home/max/build/master-x86_64/x86_64-unknown-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:104
    #2 0x7fd84f914d18 in std::string::_Rep::_S_create(unsigned long, unsigned
long, std::allocator<char> const&)
/home/max/build/master-x86_64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:607

SUMMARY: AddressSanitizer: heap-use-after-free
/home/max/workspace/downloads/gcc/libsanitizer/asan/asan_interceptors.cc:536
__interceptor_strlen
Shadow bytes around the buggy address:
  0x0c067fff9da0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff9db0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff9dc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff9dd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff9de0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c067fff9df0: fa fa fa fa fa fa fa fa fa fa fa fa fd fd fd[fd]
  0x0c067fff9e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff9e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff9e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff9e30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff9e40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
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
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  ASan internal:           fe
==26271==ABORTING


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]