From: Julian S. <jse...@gm...> - 2024-06-16 08:33:22
|
> As Nick already suggested, start with --track-origins=yes. That should be the first thing to try. > As an alternative (if your build times are short or it's difficult to debug > the code with gdb) then you can 'instrument' your code with conditions. For > instance, if you think the variable "widget" is the culprit, then somewhere > before the reported error add something like > > if (widget == 0) > { > std::cout << "widget condition true\n"; > } Agreed; this is useful if --track-origins=yes doesn't help. A somewhat more general way to force an immediate test is #include <valgrind/memcheck.h> ... VALGRIND_CHECK_MEM_IS_DEFINED(pointer, length) or VALGRIND_CHECK_VALUE_IS_DEFINED(lvalue) I've found those two to be useful in tracking down difficult errors. J |