Andrew: PageFaults and other stuff

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Andrew: PageFaults and other stuff

Post 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?
Andrew

Re:Andrew: PageFaults and other stuff

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Andrew: PageFaults and other stuff

Post 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
Post Reply