Closed AlekseyPanas closed 1 year ago
Inconsistency usually implies accessing uninitialized memory. Seg fault should be a byproduct of that.
Can you build in debug and use gdb to print the call stack?
On Linux, please do gdb ./intersections
use command r
to run and bt
to print call stack leads to seg fault.
Im on mac, so I tried lldb but it didn't work. However, I was able to track down the seg fault with print statements. You were right about it accessing uninitialized memory. Turns out I was adding the leaf pairs in an inconsistent manner (Sometimes (A,B), sometimes (B,A)) so when intersections.cpp went to index, it would index into the wrong array (thus sometimes landing on uninitialized memory).
Running intersections on default models (knight and cheburashka) seems to have inconsistent behavior for me. I make the executable and run it multiple times. Rarely it gives me a seg fault, other times it runs but gives inconsistent point mismatches. The seg fault seems to occur within intersections.cpp and not my function.
I made sure that leaf pairs are only added if both are not null (as a sanity check) but I also accounted for nullptr subtrees in the function. What bugs me is how could it possibly seg fault inconsistenty when the code is not being recompiled?