It's the system architecture's fault
It is astonishing that modern systems use system architectures that do not automatically prevent buffer overflows, dangling pointers, and similarly pathological situations.
There are -- and have been for a very long time -- any number of system architectures that simply do not allow such situations to arise. Methods include completely separating object code from data areas, providing hardware checks on all memory accesses, and automatic garbage collection for all processes.
As matters stand, avoidance of the resultant problems rests on the shoulders of the programmers, and given the size of modern programming teams, it is inevitable that no software is entirely free of such glitches. From my p.o.v., it's time to abandon architectures that allow these types of programming errors to be made in the first place.
The sad part is that the Intel architecture is quite capable of supporting such hygienic measures -- or so I have been led to believe.