> Assuming the bad index was always present, I thought I might catch it by instrumenting accesses to global arrays. Using ASan was a possibilty, but I believed enabling checking globally on a program full of unrelated memory issues would be too noisy to be of use.
I generally think that all the issues ASan reports are worth fixing. And for a mature program that's had many kinks worked out, there's probably a not-too-enormous number of memory issues. And if there were they probably all still deserve fixing.
> Games often prefer targeted debug features for specific systems or types that are toggled by their own compile-time switches and don't depend on individual compiler extensions.
Other debug features worth considering are listed below. Not all of them depend on compiler features. Some are more security oriented but can end up identifying functionality bugs along the way.
-D_GLIBCXX_DEBUG
-D_FORTIFY_SOURCE=1 [1]
-D_LIBCPP_DEBUG [2]
-fstack-protector [3]
Of course, I'd probably still start with ASan/UBSan/TSan anyways. But these are good, too. Especially since this is a C++ project, the C++ library debug modes are handy.[1] https://www.redhat.com/en/blog/enhance-application-security-...
[2] https://releases.llvm.org/14.0.0/projects/libcxx/docs/Design...
[3] https://developers.redhat.com/articles/2022/06/02/use-compil...
[citation needed]
People tend to take this stuff seriously if you're working with Good codebases. These generalizations are categorically incorrect, from my experience.