[CRASHFIX] Stop vehicle missing frame check from causing crash by using typical part iteration loop. Optimize too. #3500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
* Prevent vehicle::add_missing_frames from needlessly triggering precalc_mounts/find_* etc multiple times
gcc linux with -O3 results in:
Program received signal SIGSEGV, Segmentation fault.
vehicle::add_missing_frames (this=0x8972df0) at vehicle.cpp:99
99 int next_y = it->mount_dy;
(gdb) bt
#0 vehicle::add_missing_frames (this=0x8972df0) at vehicle.cpp:99
#1 0x0853d0f2 in vehicle::load (this=0x8972df0, stin=...) at vehicle.cpp:84
#2 0x082913a7 in mapbuffer::unserialize (this=0x865a040, fin=...) at mapbuffer.cpp:412
#3 0x08291a2a in mapbuffer::load (this=0x865a040) at mapbuffer.cpp:248
#4 0x0827c27c in main (argc=0, argv=0xbffff7a4) at main.cpp:87
(gdb)
This fixes the crash in -O3 and unoptimized.