Page 1 of 1

Andrew: PageFaults and other stuff

Posted: Wed Sep 17, 2003 1:26 am
by Pype.Clicker
moved out of the previous thread
initial post by Andrew
but ....
main function:
int main(){
// everything is fine till next line
printf(" booom1 %u", Floppy::TickCounter); //Page Fault
return 0;
}
if i want to print value of the variable which is being changed by the IRQ0 handler i get page fault exception.
why? i can't use it that way? or maybe this is a bug in memory manager? or smth else?

and if i comment that printf line i get general protection error. is there smth i should do before exit?

Re:Andrew: PageFaults and other stuff

Posted: Wed Sep 17, 2003 2:20 am
by Andrew
well, before the return operation i added this line

Code: Select all

__asm__ __volatile__("cli \t\n hlt \t\n");
and it solved the problem ( ::) well at least i think so),
what i mean is that i get TickCounter value printed, and code above woks fine too.

so is this is a good way on solving my problem or not?
a would be really appreciated if someone gave me some explanation about this situation.

thank you in advance.

Re:Andrew: PageFaults and other stuff

Posted: Wed Sep 17, 2003 2:31 am
by Pype.Clicker
There are 2 options:
- either you have no valid return address when 'main' is running (for example if you had a jmp main rather than a call main or something alike), in which case returning is a BadIdea (tm)
- or you have something wrong with your stack, like a misinitialized pointer or a buffer overflow BigBug (tm) somewhere, which destroyed the return address information, in which case your patch is just delaying the RealProblem (tm)

BadIdea, BigBug and RealProblem are trademarks of their respective ownerz