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.
I'm writing a shared_ptr class for my C++ protected mode kernel, but the kernel randomly page faults (cr2=0x98c30008 error_code=0) when I add a variable to the class and I have no clue where to even start looking for the underlying problem. Does anyone have any ideas?
If it's not spurious (e.g. you can find the reason by examining the corresponding page table entry, page directory entry, etc) then there's a bug in your code. The error code says the page fault was caused by a "not present" page, so either you didn't map a page when you should have, or you tried access something that you shouldn't have.
If it is spurious (e.g. occurs for no apparent reason) then your kernel failed to invalidate TLBs properly.
The first step would be to determine which of these is happening.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
It's really spurious (and I realized that I wasn't invalidating the TLB). Unfortunately, when I added that code in, QEMU stopped booting my kernel (hangs at main GRUB screen, see my other thread).
Turns out it triple faulted, and that's what QEMU displayed on the screen when it reset (but it's not what was last printed by my OS, strange). Now I just need to track down why it's triple faulting (I thought I had my IDT installed correctly, guess not).