Incorporates ArduPilot ChibiOS pulls #99 , #100, and #101 to fix issues
in the SD card drivers which can cause the flight controller to hang
(and subsequently watchdog) or the logging thread to fall asleep forever
and be unable to recover.
Both results can happen during flight. The former result happens on F4
and F7 only, the latter happens on H7 too. The issues are mostly
triggered by an SD card that is rapidly connected and disconnected, such
as vibrating in its socket, though random card communication failures
could trigger them too. They have existed for a very long time.
Testing was performed on Cube Black (F4), Pixhawk 4 Mini (F7), and Cube
Orange (H7). The issues were reproduced using an SD card extender, then
deliberately unlocking and carefully wiggling the flat flex cable. After
these patches, this can be done apparently indefinitely and the logging
thread always comes back and logging restarts after the SD card is
securely attached again.
Note that some boards are evidently vulnerable to this wiggling shorting
out the SD power rail and resetting the CPU too. Software can't fix
that, so vehicles with poor SD card connections need to be fixed
properly!
it was possible for a runtime allocated subscriber, client or server
to trigger a call to a pure virtual handle_message function in the
HandlerList class as the constructor ordering inserts the handler into
the list before the vtable pointer is updated to the vtable for the
child class. The same issue happens on destructor
this could happen in a couple of places in ArduPilot:
- the MPPT battery driver does runtime allocation of a client on an
R/C switch
- the DroneCAN_Serial client is started after the thread starts so
packet processing is started
thanks to Thomas and Sid
Fixes the following issues:
* Compound array elements subject to tail array optimization could be
decoded incorrectly, causing a decode failure.
* Invalid array lengths could be sent over the wire if a
longer-than-max array was encoded (though only the max number of
elements was sent).
* Lengths were not validated when decoding arrays of compound elements
using TAO, causing memory corruption if an invalid length was received.
* Union tags were not validated, causing undefined behavior if an
invalid tag was received.