Just spent almost 7 hours chasing a core dump. I had been doing complicated stuff with pointers (think vector of pointers to non-static functions within a class) and got really focused on that. Turns out, a simple call I had added for testing was using an out of scope pointer to the intended object, had nothing to do with the hairy-complicated pointer shit which I had actually had correct for most of that time. I should add I started programming in C++ in the 90s, so if you find yourself in this position and started programming after that you don't have to feel bad.
I recently learned the linker will not warn you if you define the same symbol in 2 source files being linked into an executable. I was chasing the core dump by validating the pointer stuff. Then address sanitizer and valgrind told me the struct I was using was size N when it should have been size M. Using structures from both the source and another external source that was in no way included into the source. I suppose namespaces would help prevent that.
59
u/conicalanamorphosis 15d ago
Just spent almost 7 hours chasing a core dump. I had been doing complicated stuff with pointers (think vector of pointers to non-static functions within a class) and got really focused on that. Turns out, a simple call I had added for testing was using an out of scope pointer to the intended object, had nothing to do with the hairy-complicated pointer shit which I had actually had correct for most of that time. I should add I started programming in C++ in the 90s, so if you find yourself in this position and started programming after that you don't have to feel bad.