Ugh with C++ (which is what most the world uses) this should be a solved problem.
The issue is that so much code still relies on C (which is fair enough) but also ancient broken C++ with raw pointers or some amateur shite developed by a beginner (or python developer out of his element) who doesn't know what a smart pointer is.
It isn't helped by the fact that a lot of C++ developers don't care about safety. Some libraries such as GLM even started defaulting to no zero initialisation of their math structures just for a little bit extra speed. This is great but should never be the default. GUI libraries are notorious for using raw pointers. Once you get a handle on a Button*, you have no idea if it is valid or not once widgets start to change. You have to rely on your assumptions which are not guaranteed.
The standard library smart pointers also don't quite cover a lot of typical memory errors. For example it is very easy to get a dangling "this" in a large convoluted codebase. No-one seems to be really interested in fixing it.
If anyone is interested; I drafted up a "safe" version of shared/weak and vector classes as part of my "sr1" prototype. You can also see a minimal test suite here for an example of some stupid errors that it protects against that C++ developers still make: https://github.com/osen/sr1/tree/master/src/tests
The library is shite with multi threading. An older version had a global lock which was quite slow. Then I realised multithreading was inherently unsafe anyway so ripped it out and kept mutexes / semaphores as a manual exercise ;)