This is exactly what Cardano is trying to avoid with Haskell based smart contract language and formal verification. <a href="https://cardanodocs.com/technical/plutus/introduction/" rel="nofollow">https://cardanodocs.com/technical/plutus/introduction/</a>