





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A class presentation from a computer systems course (cs 213) focusing on memory management in c programming. It covers various memory-related bugs, such as dereferencing bad pointers, reading uninitialized memory, overwriting memory, and referencing nonexistent variables. The document also discusses debugging techniques, including using conventional debuggers, debugging versions of malloc, binary translation, and garbage collection.
Typology: Slides
1 / 37
This page cannot be seen from the preview
Don't miss anything!






























Introduction to Computer Systems
class16.ppt
left to right
(type)
sizeof
right to left
left to right
left to right
left to right
left to right
left to right
left to right
left to right
left to right
left to right
left to right
right to left
right to left
left to right
class16.ppt
The classic scanf bug scanf(“%d”, val);
for (i=0; i<N; i++) {p = malloc(N*sizeof(int)); int **p; p[i] =
(^) malloc(M*sizeof(int));
Off-by-one
for (i=0; i<=N; i++) {p = malloc(N*sizeof(int *)); int **p; p[i] =
(^) malloc(M*sizeof(int));
strcpy(t, s);char s[8] = “1234567”; char t[7];
gets(s);int i; char s[8];
/* reads “123456789” from stdin */
(^) int val) {
while (*p && *p !=
(^) val)
p += (^) sizeof(int);
Forgetting that local variables disappear when a
function returns
int *foo () { return &val;int val;
Evil!
for (i=0; i<M; i++)y = malloc(Msizeof(int));...free(x);
slow, long-term killer!
foo() { int (^) x = malloc(Nsizeof(int));
return;...
class16.ppt