mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
* test(mavsdk): fail test cases on sanitizer reports The runner only looked at the mavsdk_tests exit code, so ASan, TSan and UBSan reports from px4 ended up in the logs without failing anything. Scan the output of all processes for sanitizer report markers and fail the test case if any appear, including leak reports printed at exit. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(mavlink): allow more boot time when sim speed factor is set In lockstep SITL the boot timeout is measured in sim time, but the remainder of rcS after mavlink start runs in real time. At high speed factors (e.g. 30x in mavsdk_tests) the 20 s sim-time timeout expires before rcS reaches "mavlink boot_complete", triggering a spurious error. Use 40 s when PX4_SIM_SPEED_FACTOR is set. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(mavlink): don't share vehicle_status subscription across threads send_autopilot_capabilities() (also called from the receiver thread on REQUEST_MESSAGE) and the SETUP_SIGNING armed check (receiver thread) used the same _vehicle_status_sub as handleStatus() on the main thread. Besides being a data race flagged by TSan, advancing the subscription's generation from another thread can make handleStatus() miss a vehicle_status update. Use local subscriptions for those two callers. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(gyro_fft): do initial sensor selection on the work queue init() ran SensorSelectionUpdate() on the shell thread, which registers the gyro callback before setting _selected_sensor_device_id, _gyro_fifo and the gap perf counter. A gyro sample can then start Run() on the work queue while those are still being written, which TSan flagged. Schedule Run() instead and let it do the first selection. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(logger): copy events into an aligned struct before access The event was copied into _msg_buffer at an offset that isn't aligned for event_s and then accessed through an event_s pointer, which is undefined behaviour (flagged by UBSan) even for single-byte fields. Copy into a local event_s, adjust it there and memcpy it into the buffer. The bytes written to the log are unchanged. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(manual_control): don't convert negative kill gesture time to unsigned MAN_KILL_GEST_T is negative by default to disable the gesture, which made the hysteresis time a negative float converted to hrt_abstime, undefined behaviour flagged by UBSan. Clamp to 0; the gesture is only evaluated when the parameter is positive. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(mavlink): define mavlink_channel_t with all 6 channels The library's mavlink_channel_t ends at MAVLINK_COMM_3, and channels 4 and 5 were created by casting out-of-range values to the enum, which UBSan flags. Use the library's HAVE_MAVLINK_CHANNEL_T hook to define the enum with all channels when MAVLINK_COMM_NUM_BUFFERS is 6. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(mavlink): clamp DISTANCE_SENSOR fields to their integer ranges A slightly negative range reading (seen with SIH near the ground) was converted to the uint16_t distance field, which is undefined behaviour flagged by UBSan. Clamp distances and covariance to their field ranges. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(sensors): skip baro GNSS offset without baro samples With no baro samples accumulated, the average pressure was 0/0 = NaN. A NaN delta altitude poisons the offset low-pass filter, so the baro GNSS autocal could silently never complete. Skip the run instead, and leave the GNSS sample for the next one. Flagged by UBSan. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(mavlink): don't divide by zero rate without variable rate streams Without variable rate streams the bandwidth multiplier was a division by zero, and the resulting inf was only clamped away later. There is nothing to scale in that case, so use 1. Flagged by UBSan. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(gyro_fft): skip peak interpolation for a zero or flat spectrum Quinn's estimator divides by the peak bin magnitude and by 1 - ap and 1 - am, which are zero for a zero or flat spectrum (e.g. noise-free SIH gyro data). Return NAN, the existing no-estimate value, instead. Flagged by UBSan. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(logger): don't compute write rate before time has passed Right after a log file is opened the elapsed time is zero, so the write rate was a division by zero. Report 0 until time has passed. Flagged by UBSan. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(battery): check cell voltage before computing scale Check the filtered cell voltage before dividing by it rather than relying on the NaN/inf result of the division. Flagged by UBSan. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(perf): report 0 rms for a single event With one event the rms was computed as 0/0. Flagged by UBSan. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(matrix): only normalize axis for non-zero axis-angle rotations The axis was normalized before checking for a zero angle, dividing by a zero norm (e.g. SIH with no rotation). The result was already unused in that case. Flagged by UBSan. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> * fix(mathlib): return infinite cutoff for unconfigured AlphaFilter A time constant of zero means no filtering; return an infinite cutoff frequency explicitly instead of dividing by zero. Flagged by UBSan. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch> --------- Signed-off-by: Julian Oes <julian@oes.ch>