Also check out INAV if you want to build a more DJI-style drone, this would be the Flight Control software: https://github.com/iNavFlight/inav
Other FC software include ArduPilot for more of a groundstation approach, while Betaflight, EmuFlight, and similar FC software are what FPV race, freestyle, and cinematic pilots prefer.
Also, Ardupilot blows INAV completely out of the water for reliability, at least for fixed wing craft. I've switched all my planes to it from INAV.
The biggest issue is that this usually happens during automatic modes, which are things like "return to home", which you usually use when you've lost control or video and you really want RTH to work reliably. I can't risk a plane falling onto a car or person, so I use ArduPilot, whose auto modes are impressively accurate.