-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
add integer bound check #28790
base: master
Are you sure you want to change the base?
add integer bound check #28790
Conversation
It is strange, but not impossible, that this should crash. What platform are you running on and what message are you trying to send? The check needs to be moved to only be done if |
I'm not 100% sure what you mean by platform. I'm only using a simulation which I start with: I encounter the problem if I send the command_long over mavlink using a self written python program with the following parameters:
These parameter values are random, but they should not lead to a crash. I also noticed the same problems using different command, e.g. 195-MAV_CMD_DO_SET_ROI_LOCATION The stack trace is the following:
Thank you for your recommendation regarding the position of the check. I will adjust the code accordingly. |
0074020
to
29928fd
Compare
Thanks for providing the command you used. By platform I mean processor type, operating system name and version, compiler name and version, etc. Ardupilot SITL is usually run on Ubuntu x86_64 so that's the least likely to cause problems. Thanks also for updating the code, but there are a lot of casts in Ardupilot so it's concerning that this one should crash. This is undefined behavior so we are clearly in the wrong, but I'd like to be able to replicate the problem myself and better determine impact on common platforms and what other changes we might need to make. |
Well I expected this to be a semi-exotic platform but sure enough it's easily triggerable on x86_64 (using my Nix flake). You can use mavproxy and the command It also happens on a non-debug build (you selected a debug build with I will discuss this with the team and see if this is the right fix and if we need to do more.
|
I think @peterbarker should look at this, though I think the fix is correct. I would have used constrain_float() though. |
Note that we deliberately ignore SIGFPE on non-SITL. If you want to see what a real flight controller would do in a situation like this then set "SIM_FLOAT_EXCEPT = 0" and SITL will ignore FPE in the same way a real flight controller does. |
Much larger change, but we should probably reject the command in this case. |
29928fd
to
8561dfb
Compare
Done. |
I agree with that. But I'm not sure if I can implement this by my own. |
When sending mavlink command_long messages with some arbitrary parameters, I noticed random crashes in the simulation. I looked into it and found, that the simulation always crashes, when I send a parameter >215 or <-215 for a coordinate. This was due to a integer over/underflow in the conversion from long to int.
I added the necessary checks to the converting function and now I do not longer notice the problem.