There is no such implementation!this randon behaviour come out with simple inclusion of a simple function (any kind)???If you reduce the code, it works.... if add a simple function, for example, to print one byte on screen...

-Stack is at 0x8fec;-Page fault at 0x600e20a due to an instruction at 0xc0005ff7 linear, 0x105ff7 physical;-PDBR at 0x9c000 physical

It does certainly look like corruption here. Because you can replicate the bug with ease and certainty (the inclusion of a function) you can use that as an advantage by using breakpoints and verifying the integrity of the in memory image and data structures and watching for changes.

The instruction mov dword ptr ds:0xf00ba40, 0x000a6f00 appears to contain two invalid values when compared to the other instruction... the offset displacement and immediate value.

Have the compiler (not Bochs debugger) output a disassembly of that function to check what that instruction is supposed to be. Do this for both kernel sizes (when it works and when it crashes) and compare. Post results here please -- code is preferred if you could point out the faulting instruction that causes the crash.

It should also be noted to be very cautious with the pf_atexitlist = (_PVFV *)0x5000; line. This was done in the series OS for simplicity only (and due to it being introduced prior to a mm); it is highly recommended to allocate memory dynamically or properly reserve a region for it.