https://bugs.kde.org/show_bug.cgi?id=444264

            Bug ID: 444264
           Summary: Valgrind is not able to detect sample array bound read
                    and write.
           Product: valgrind
           Version: unspecified
          Platform: Ubuntu Packages
                OS: Linux
            Status: REPORTED
          Severity: critical
          Priority: NOR
         Component: memcheck
          Assignee: jsew...@acm.org
          Reporter: wanglllg2...@163.com
  Target Milestone: ---

SUMMARY


STEPS TO REPRODUCE
1. use the following code as a test program
  #include <iostream>
  using namespace std;

  void func() {
    int a[12] = {0};
    a[13] = 100;
    std::cout << "end: " << a[13] << std::endl;
  }

  int main() {
    func();
    return 0;
  }


2. compile the code using command:  g++ -g -O0 ./test.cpp -o ./test

3.run the valgrind with:  valgrind --tool=memcheck --leak-check=full ./test

OBSERVED RESULT
==4613== Memcheck, a memory error detector
==4613== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4613== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==4613== Command: ./test.exe
==4613== 
end: 100
==4613== 
==4613== HEAP SUMMARY:
==4613==     in use at exit: 0 bytes in 0 blocks
==4613==   total heap usage: 2 allocs, 2 frees, 73,728 bytes allocated
==4613== 
==4613== All heap blocks were freed -- no leaks are possible
==4613== 
==4613== For lists of detected and suppressed errors, rerun with: -s
==4613== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

EXPECTED RESULT
writing exceeding the bound of the array shall be detected

SOFTWARE/OS VERSIONS 
Windows: N.A.
macOS: N.A.
Linux/KDE Plasma: Ubuntu 18.04 LTS, Ubuntu 20.04 LTS
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
if you change the size of array to 10, and access array[11], the program will
crash with stack smashing and the valgrind works well

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to