What can cause a C program to crash the operating system

I recently discovered that a fairly large imaging program I am writing in C on a Windows 8 computer has a bug when used in special circumstances. Unfortunately, the error is causing my entire computer to go to a standstill, so my only option is to pull the plug to the computer (especially annoying when I work remotely ...)

Since this is an imaging program, I can't just stuff it with print statements to isolate the problematic section - the problem occurs somewhere in a loop that is called billions of times, so adding printf slows it down to the point that it takes days to reach an unsuccessful iteration ...

So I understand that if this question is too broad, since it is not reasonable for me to exclude all code that might be causing my problem, I just ask

What are the circumstances under which C code can actually freeze the entire OS instead of seg-crashing or stopping the program?

When I search for a problem I see golf questions like this

C program that crashes the system (shuts down the system)

That's not what I'm asking - obviously I didn't write the system ("shutdown") anywhere in the loop.

Being most familiar with python and java, this problem is not what I'm used to, but in my experience,

  • Division by zero causes seg to fail
  • Accessing memory accidentally, slightly outside of the intended array, causes a seg error (sometimes a little down the road).
  • Access to protected memory leads to program hang
  • Stack overflow causes seg error
  • Allocation of uninitialized pointer causes segregation

Is this impression false - could these cases crash the entire system? When am I missing? Does it depend on my gcc version or my permission status?

I have not been able to reproduce it on another operating system yet as it requires multiple dependencies to run the entire program.

If my only option is to sit for days waiting for the program to work with print statements, or avoid weird situations, then of course so be it. I am looking for key places to find the error.

+3


source to share


2 answers


On modern systems with hardware privilege separation between user mode and kernel mode and an operating system that functions to properly configure these mechanisms, you simply cannot take the system out of the user mode process.

Any of these errors get caught in the CPU trap, which cause exception handlers in the OS, which quickly pull the plug on your system.

If I had to guess, a piece of hardware is overheating or not working properly:

  • Overheating of the processor due to poor thermal conductivity with the heatsink
  • Malfunction / insufficient power supply
  • Failed DIMMs
  • Hard drive failure
  • CPU failure
  • Failed / overheated GPU


I've seen cryptocoin-mining software bring the system to its knees because it pushes the limits of the GPU. When the card is locked / reset, the driver will get confused or locked and eventually the system will reboot.

Your system does almost nothing when you are just surfing the Internet, etc. But if your system locks up when you run a CPU-intensive application, it might reveal issues you didn't know where to find.

While it lags a little behind, it falls into one of those gray areas between hardware and software. I would stress test your system by monitoring CPU / GPU / memory temperatures and supply voltages. Check out MemTest86 , Stresslinux .

+2


source


The most trivial reason for freezing an OS is "full memory". If you have processes that use most of the memory, then your system will change from main memory (usually RAM) to secondary memory (usually disk), which leads to a very huge overhead ... As a user, what do you usually you see a computer that is almost frozen, sometimes so frozen that you think it crashed. If your OS is poorly designed, it sometimes crashes!



0


source







All Articles