Debugging a Crash in OpenRCT2
voidstar.tech
voidstar.tech
As additional complication, debug symbols are often removed from the binary post-build to reduce binary size. The `strip` utility either discards debug symbols entirely, or it puts them in a separate folder as .dbgsym filses. See the gdb `debug-file-directory` option and the `add-symbol-file` command.
I take it the author didn't know this method, or... I might be missing something as to why that wasn't done?
Sadly workplace politics prevent me from doing that and somehow everyone else is productive enough, so I'm just slowly getting used to living in Visual Studio.
> 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.