Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid nullptr dereference on bad rcmap value entry #28033

Merged

Conversation

peterbarker
Copy link
Contributor

Setting a bad rcmap entry doesn't just hard-fault the autopilot but ensures you have to reset all of your parameters before you have a working autopilot again.

This has been the case for a very long time. But perhaps we should fix it?

Checking the library return values for nullptr doesn't help if we have already persisted the parameters - next time you boot you'll not populate e.g. channel_roll with a valid pointer and will then segfault. So we use a "dummy channel" instead.

A new record for shortest autotest.

@peterbarker peterbarker force-pushed the pr/rc-channel-not-null-fixes branch from 9112bc4 to 3005d14 Compare September 8, 2024 23:53
@peterbarker
Copy link
Contributor Author

I've added an additional patch to MSP to avoid a similar problem.

There are almost certainly more in the codebase, but I want to know this is an acceptable solution before patching them all.

@peterbarker peterbarker force-pushed the pr/rc-channel-not-null-fixes branch 2 times, most recently from b0c3d87 to d00f1b5 Compare September 9, 2024 00:15
@peterbarker
Copy link
Contributor Author

Problems around optimisation again on Pixhawk1-1M-bdshot; elf-diff shows many small increases in random methods

Board                    AP_Periph  blimp  bootloader  copter  heli  iofirmware  plane  rover  sub
CubeOrange-periph-heavy  *                                                                     
Durandal                            -16    *           8       -56               -256   64     72
Hitec-Airspeed           *                                                                     
KakuteH7-bdshot                     40     *           64      40                56     208    56
MatekF405                           16     *           8       32                176    0      80
Pixhawk1-1M-bdshot                  56                 344     384               280    48     32
f103-QiotekPeriph        *                                                                     
f303-Universal           *                                                                     
iomcu                                                                *                         
revo-mini                           32     *           16      136               112    48     56
skyviper-v2450                                         40                                      

@@ -8,16 +8,17 @@
*/
void Plane::set_control_channels(void)
{
// the library gaurantees that these are non-nullptr:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// the library gaurantees that these are non-nullptr:
// the library guarantees that these are non-nullptr:

@peterbarker peterbarker force-pushed the pr/rc-channel-not-null-fixes branch from d00f1b5 to 1089f6c Compare September 10, 2024 01:58
@peterbarker peterbarker merged commit 1542290 into ArduPilot:master Sep 10, 2024
95 checks passed
@peterbarker peterbarker deleted the pr/rc-channel-not-null-fixes branch September 10, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants