Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
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 '12 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 –  Miro Oct 31 '12 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 '12 at 8:13

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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