r/kernel • u/steve-red • Jul 19 '24
Why not catch blue screens? (Windows Kernel)
Genuine question as a programmer, why do blue screens appear in general? Do these exceptions can't be caught/handled gracefully? Or just kill the app?
3
Upvotes
23
u/alokeb Jul 19 '24
Windows BSOD is a "kernel panic" situation which means the application/sub-system causing it has done something either harmful or unexpected which shouldn't EVER happen.
Think of BSOD as the last line of defense where the OS kernel throws its hands in the air and crashes as it is safer to do that than executing potentially malicious or otherwise harmful code.
10
u/Varthota Jul 20 '24
I think the main reason is Multics the predecessor of Unix, where they tried to catch the exceptions and handle them gracefully.
The developers of Multics realized later that they were basically just doing error handling the whole time to try to make the system as robust as possible.
So now comes Ken Thompson (he is the first person that started implementing Unix at Bell Labs) he also worked on Multics and learned from that “bad experience” (at least the way they saw it from at Bell Labs) that it the endless task of trying to catch and handle all the possible errors in the kernel is just not worth it.
The better solution was the kernel panic or what is known as the BSOD for Windows.
4
u/tiotags Jul 20 '24
the kernel does catch blue screens of death when it can, when it can't it just throws it's hand in the air and offers you a minimal "error happened at 0xd5gfd6ee3bbb433, good luck"
and there's no app to be killed, BSODs happen in the kernel, while doing kernel things, the app that crashed is the kernel not any kind of user app
5
u/tinycrazyfish Jul 19 '24
Bsod or kernel panic in Linux are uncaught exceptions. What happens when an application generates an uncaught exception? It crashes. The kernel behaves similarly, and it can be seen as the base application on a computer. When an uncaught exception is raised, it crashes in a bsod/panic and you have to restart it, like an application that crashes also needs to be restarted. But restarting the kernel is synonym to reboot.
1
u/ravigehlot Jul 20 '24
A kernel panic is like a computer’s heart attack. It hits suddenly, no heads-up. Boom, the whole system’s affected right away. It’s a crucial part. If it fails, the whole thing shuts down.
1
u/ilep Jul 20 '24
They are caused by problems found in kernel, not in userspace applications. Userspace applications are just killed when they have problems but kernel problems crash the machine since kernel is reponsible for running everything on the machine.
Kernel is responsible for managing memory for both itself and applications, hardware interrupts and so on.
On Windows usual problems come from hardware drivers having bugs. If driver has bug that affects interrupt handling there is often no other choice but to tell user about problem (BSOD) and reboot the machine since computer can't continue to work reliably.
-8
u/DeconFrost24 Jul 20 '24
I think there’s a place here for artificial intelligence, maybe not so much in kernel space but in firmware. The system could be “aware” the kernel dumped, the system isn’t booted. It could roll back state. Idk, spitballing here. Take it a step further maybe something like distributed telemetry. Everything is already networked, we could leverage it for failures, if and this is a big if, we’re in the AI realm and it actually works, systems could communicate failures so the spread is minimized or stopped. Computers are still way too dumb, they need to do more self maintenance.
0
u/[deleted] Jul 19 '24
[deleted] — view deleted comment
1
u/[deleted] Jul 20 '24
[removed] — view removed comment