Generic "why are there CTD at all"

Some people are missing the point of my post. I don’t care about the scenarios that might or might not lead up to a CTD event happening. It seems such a random thing I don’t think they can be attributed to any one thing.

I am more interested (as a programmer) in why one ever happens at all. I am thinking, perhaps naively, that the OS, the programming language, and then finally the programmer should prevent any CTD ever happening. Primarily, I think the OS should be doing this. I certainly try to prevent as many problems as possible and then if an error does occur, to provide to the user as much useful information as possible. In my 40 years of programming I don’t recall a CTD in any of my software. Or indeed, of it even being a possibility. I don’t even know how I could force such a thing. I admit that I have never programmed in C, C# or C++ (except for one small embedded job), so my experience there is limited. But that is why I am asking here - perhaps someone who is a programmer in those languages can tell me.

I think that the answer given earlier seems correct. If you are interfacing with DirectX and the like, then you are perhaps losing a lot of the protections of the OS and your programming libraries.

“CTD” is a bit misleading because it’s not so much a “crash” as it is a deliberate action taken by the OS, because it saw that the application broke some rule. The OS certainly needs to be able to shut an application down for many reasons, like for example security and stability.

Direct3d obviously must be concerned about performance.

Any programming language or API can implement error handling. The question is what is the programmer allowed to do? If he is allowed to break all the rules, then certainly at some point he is going to accidentally cause a CTD.