Past MCQ/Short Response Qs Flashcards
(11 cards)
In the following code the address printed by printf belongs to which section?
int *p;
p = malloc(sizeof(int));
printf(“&p=%p\n”, &p);
Stack
Question on insertion to freelist based on malloc implementation.
Check gradescope to see Q.
Question on insertion to freelist based on malloc implementation.
Check gradescope to see Q.
Q4 review
Which assertions are true about the following code?
char * p = (int *) malloc(10);
strcpy(p, “123456789012345”);
free(p);
I. This is an example of memory smashing
II. This is a bug but the program will not crash.
III. This is an example of a wild free.
IV. The program may crash in line 3
I and IV.
What is the initial value of the reference count of an i-node of a directory and why?
It is 2, one for entry in the parent and one that refers to the current directory.
What will this do?
int fd = open(“outfile”, O_RDWR);
if (fork()) {
dup2(fd, 1);
}
else {
write(1, “hello\n”, 6);
}
It sometimes prints “hello\n” to the outfile and sometimes to the terminal
Can a free object be next to another free object in the heap?
No, they would have been coalesced.
Q9 review
What gbd command shows where a segv happened?
where