Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 1458577 Details for
Bug 1600733
Missing function name in debug output (e.g. valgrind)
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
fSource ode for reproducer valgrind errors
test.c (text/x-csrc), 1.89 KB, created by
Lukas Slebodnik
on 2018-07-12 21:22:06 UTC
(
hide
)
Description:
fSource ode for reproducer valgrind errors
Filename:
MIME Type:
Creator:
Lukas Slebodnik
Created:
2018-07-12 21:22:06 UTC
Size:
1.89 KB
patch
obsolete
>/* > * This program has various memory related problems that provide a good way > * to show off the various abilities of valgrind. To run it: > * > * valgrind <optional valgrind options> ./valgrind-tests <test number> > * > * where <test number> is between 1 and 9, inclusive. Suggested > * valgrind options to run with are > * > * --logfile=valgrind.output --num-callers=6 --leak-check=yes > */ > >#include <stdio.h> >#include <stdlib.h> >#include <string.h> >#include <unistd.h> > >void >test_1() >{ > // This test provides an example of using uninitialised memory > int i; > printf("%d\n", i); // Error, i hasn't been initialized > > int * num = (int*)malloc(sizeof(int)); > printf("%d\n", *num); // Error, *num hasn't been initialized > free(num); >} > >void >test_3() >{ > // This test provides an example of reading/writing off the end of > // malloc'd blocks > int * i = (int*)malloc(sizeof(int)*10); > i[10] = 13; // Error, wrote past the end of the block > printf("%d\n", i[-1]); // Error, read from before start of the block > free(i); > test_1(); >} > >void >test_4() >{ > // This test provides an example of reading/writing inappropriate > // areas on the stack. Note that valgrind only catches errors below > // the stack (so in this example, we have to pass a negative index > // to ptr or valgrind won't catch the problem) > int i; > int * ptr = &i; > ptr[-8] = 7; // Error, writing to a bad location on stack > i = ptr[-15]; // Error, reading from a bad stack location > test_3(); >} > >void >test_7() >{ > // This test provides an example of overlapping src and dst > // pointers in memcpy() and related functions > char big_buf[1000]; > char * ptr_1 = &big_buf[0]; > char * ptr_2 = &big_buf[400]; > memcpy(ptr_1, ptr_2, 500); // Error, dst region overlaps src region > test_4(); >} > >int >main(int argc, char**argv) >{ > > test_7(); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1600733
: 1458577