[Not really OT] Crowdstrike Analysis: It was a NULL pointer from the memory unsafe C++ language.

Walter Bright newshound2 at digitalmars.com
Thu Jul 25 06:48:44 UTC 2024


On 7/24/2024 7:32 PM, Richard (Rikki) Andrew Cattermole wrote:
> The problem isn't going into unsafe code, its that you made an assumption that 
> either is the reality, or is never correct and is guaranteed to error out.

A null pointer seg fault is not an unsafe thing.

Memory unsafety is about memory corruption. A seg fault is not memory corruption.

Consider:

```
int* p;
*p = 4; // seg fault, program terminates
...
int* q;
assert(9); // program terminates
```

Both of these cases are memory safe. Both default to summarily terminating the 
program. Both can have handlers installed to "recover" and do something nice.

Before there was hardware memory protection, with DOS writing through a null 
pointer meant scrambling the operating system, leading to all kinds of horrible 
things like scrambling your hard disk as well. Imagine trying to find what went 
wrong. It's like your house burned to ashes and now you have to figure out the 
source of the blaze.

When protected mode became available, it was a miracle. Having the hardware 
check *every* pointer *every* time for validity was a huge advancement. And the 
code still runs at full speed!

Even better, you could get a stack trace pointing at the bug in your code.

I used to spend *weeks* trying to find memory corruption bugs. Today it's a few 
seconds. Seg faults are a great gift!


More information about the Digitalmars-d mailing list