5 ms·
> Oh you sweet summer child Should have clarified. On the embedded systems I work on, generally Cortex-M4, you set an MPU region on address 0x0 and it turns in
by tyhoff 6y ago
> Oh you sweet summer child
Should have clarified. On the embedded systems I work on, generally Cortex-M4, you set an MPU region on address 0x0 and it turns into a hardfault, so it's pretty easy to catch.
- saagarjha 6y agoA good optimizing compiler can remove the dereference entirely if it notices, unfortunately.
- sigjuice 6y agoHow big is this MPU region? Pointers to large structs can easily allow access past the protected region.
- lmm 6y agoIf you were writing assembly that would be reliable, but in C it isn't. The compiler knows that NULL dereferences are undefined behaviour and so won't necessarily compile them into memory accesses.
- btrask 6y agoYeah, in C you need to use assertions (or simple checks) for things that might be null. That said the compiler isn't infinitely smart (thank god) and complex null derefs will "safely" make it to runtime. (What a sad world we're in.)