Yes - the debugger Use the debugger … get the stack trace when in crashes, inspect the local variables the cause is usually staring you in the face*
Except when it isn’t and you spend 2 days hunting*
**I’ve noticed that with a bit of experience the 2 days is now more like 2 minutes for a difficult one… but it definitely used to be two days.
Break points before everything is screwed up usually helps more!
Last occasion of the thing you mention, it was a memory corruption copying a small negative number of bytes casted to unsigned int for memcpy. No way to find that by staring at the debugger. It was even in a different thread!
unsigned int
I go with DBG() and starting from a terminal…
AAA (Almost Always Asan) (and coming in Xcode 9 Undefined Behaviour Sanitizer!!!)
Asan?
https://www.google.co.uk/search?q=asan
AddressSanitizer. Sixth result: https://www.chromium.org/developers/testing/addresssanitizer
More details about it here: https://clang.llvm.org/docs/AddressSanitizer.html