I always wondered how a kernel that became unstable, e.g. due to a BSOD or a kernel panic, is able to do specific tasks.
For example, if a Windows driver corrupts the stack of the kernel. It leads to a BSOD.
But I wonder, how does the kernel detect the stack corruption, and how is the now crashed kernel able to do complex tasks like writing a log file into an NTFS directory?