0

I'm developing OpenGL game and I've copied portion of code with similar function code was partially modified for it's new function, but there was still some bugs. This code was calling OpenGL rendering functions with wrong data, parameters.

After calling OpenGL functions with wrong data/arguments whole system freezes and I'm not even able to switch to console CtrlAltF1.

This disappoints me, because Linux should be stable software/OS. Then, why can bugged OpenGL program crash whole system?

3
  • 2
    Why do you expect the library+kernel layer+driver+hardware to be 100% bug-free? I agree that shouldn't happen, but OpenGL calls aren't exactly your everyday pure-userland function calls.
    – Mat
    Oct 27, 2012 at 9:29
  • @Mat I don't expect it to be bug free, but I'd like it to throw any exception(SIGSEGV?) and crash program instead of whole system
    – kravemir
    Oct 31, 2012 at 7:42
  • ultrasawblade's answer explains it. Part of the OpenGL pipeline is dealt with in drivers (kernel-mode) & hardware. If something goes wrong in kernel-mode, you're potentially toast.
    – Mat
    Oct 31, 2012 at 8:13

2 Answers 2

2

Given the "monolithic" nautre of the Linux kernel, an error in code that runs in the highest privilege level of the CPU, usually entitled "kernel-mode", can crash the whole system.

There are three reasons for this:

  • Such code can directly access the memory space of any other code. So it is possible for such code to corrupt the kernel itself, running drivers, etc.
  • Such code can directly access I/O devices. It's quite possible to misconfigure or set the wrong bits at wrong times on I/O devices in a way that causes the entire system to lockup. Non-buggy device drivers won't let user code do anything to hardware that could cause an unstable system, but buggy, beta, or poorly written (or wrong) drivers just might.
  • Code that encounters a problem or exception it can't handle doesn't have a higher level to "throw" to. So a kernel exception will crash the system.

So I don't know to what extent OpenGL works in the kernel or with the graphics driver but I hope this helps.

0

Modern user interface environments (Windows, OSX, Linux, mobile, etc) rely heavily on the graphics pipeline for performance.

Systems have one** graphics pipeline. All graphical programs (desktop, browser, games, etc) are separate threads which must share this single graphics context.

This creates the required conditions for multithreading problems. The threads can get deadlocked, livelocked, raced, etc.

It is likely your thread is not "playing nicely" with the desktop graphics thread, and it is locking up. Probably waiting on a resource that is no longer available (are you freeing all resources correctly?)

OpenGL is very aggressively developed, and pushes hardware to the limit. You might find that bug does not occur on other hardware.

If however, your whole system shuts down, then it is likely the actual chipset of pipeline is overheating and/or overvolting. Most hardware has sensors which cut the power if harmful spikes in load occur. Manufacturers load test their hardware and set the cutoffs accordingly.

** Single graphics pipelines are being replaced by multiple pipelines (which can 'own' separate smaller regions of the screen). This is what OpenGL's Vulkan is all about, and requires special GPU chipsets.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.