"No way to prevent this" say users of only language where this regularly happens
xeiaso.net
xeiaso.net
I imagine Java is as popular as C++ if not more. And C# is (or at least was) huge in Europe too.
Reliable software is expensive to develop; more expensive than we are willing to admit. You can either take the expense at development time by increasing development cost, or you can shift it until later and externalise the cost by making the end-user and society at large suck it up in terms of unreliability and occasional disaster.
We are at the stage the Victorians were with exploding boilers, or people in early Medieval times were with collapsing cathedrals. They fixed their problems, and so can we.