I have notice that I should initialize all pointers. for example
Code: Select all
struct foo {
void *some;
};
struct foo *foo1;
foo1 = (struct foo *)malloc(sizeof(struct foo));
Code: Select all
if(foo1->some == NULL)
// do something
I think that when I use malloc it reserve only memory for the struct foo and do not zero it. therefor sometime the memory location of struct save an old value, which does this page fault (correct me if I am wrong).
I could solve it in kernel by initialize all pointers, but user program sometimes they forget that. I can use malloc to zero the memory, which it has reserved for an object.
is that a good solution? or simply kill the user process,when page fault occur, which does not included in user space address.