Now that SITL tests run with ASan, TSan and UBSan: how do you check they would notice a change in MAVLink input handling?

PX4 PR 28943 (merged on 2 October) runs the MAVSDK SITL tests with ASan, TSan and UBSan builds, and changes the runner so that a sanitizer report fails the test case. That is a real step for catching memory errors in code that handles outside input.

A related question I am still trying to answer: how do you find out whether your tests would notice a small wrong change in that code, for example a length check turned into the wrong comparison? A sanitizer only helps if some test actually drives the input down that path.

One data point from my side, on the standalone MAVLink C parser (c_library_v2, commit 56f6435e, built with sanitizers, corpus_seeds): I planted 40 small changes, 22 were noticed and 18 were not. The count depends on the corpus, an earlier run with a different corpus gave 21. Details and the per mutation list are in my earlier thread: How do you check that your tests notice changes in MAVLink input handling?

Two questions. First, do you have a check like this for MAVLink handling in PX4 or in your own fork? Second, if I wrote a handful of targeted tests for the missed cases, would a pull request be welcome, and where would they belong?

A useful distinction here is between running SITL tests under sanitizers and demonstrating that those tests are sensitive to changes in MAVLink input-handling behaviour.

ASan, TSan and UBSan provide valuable runtime diagnostics, but they do not by themselves establish that a test suite will detect protocol-state or semantic/API behaviour changes.

One approach would be to introduce a small, controlled set of MAVLink input-handling mutations and evaluate each against the existing SITL tests.

For each mutation, I would suggest recording:

  • The exact mutation and build configuration.

  • Whether the test detected it.

  • The first observable divergence.

  • The relevant input or replay corpus.

  • Whether the observation was a sanitizer failure, protocol-state difference, semantic/API difference or outbound-message difference.

Mutations that survive should be investigated rather than immediately classified as equivalent.

This would provide a reproducible measure of test sensitivity and help distinguish runtime safety coverage from behavioural verification.

Best regards,
Yiğitcan Öztürk
PAMILANGA LTD

Hi Yiğitcan, thank you. That is how I approached it on the standalone MAVLink C parser: 40 single line mutations, each recorded with its build configuration, outcome and first observable divergence. 22 were noticed and 18 were not. Survivors are not called equivalent without evidence. Details are in my other thread.

For the PX4 side, one question is still open for anyone who works on MAVLink handling in PX4: would a small pull request with targeted tests for the missed cases be welcome, and where would such tests belong?

Best regards

Yannik

Hi Yannik,

Thank you for the clarification.

I agree that the standalone MAVLink C parser mutation study and the question of where targeted regression tests belong within PX4 should be treated separately.

Your existing results provide a useful basis for selecting test cases, particularly those with a demonstrated first observable divergence.

For a PX4-specific contribution, I would suggest starting with a small, focused PR containing one or two representative behavioural regression tests rather than transferring the entire mutation suite.

Ideally, each test would identify the MAVLink input condition, the expected PX4 behaviour and the observable assertion that would fail if the behaviour changed.

The appropriate location will depend on whether the behaviour belongs to the upstream MAVLink parser or to PX4’s own MAVLink message handling and integration logic.

I would leave that placement decision to the relevant PX4 maintainers, especially where existing test infrastructure or module ownership is concerned.

A focused PR or issue proposing the first concrete test case could make that discussion easier.

I would be interested in following the integration and reproducibility aspects of this work.

Best regards,
Yiğitcan Öztürk
PAMILANGA LTD

Hi Yiğitcan, thank you, this is a clear and useful suggestion. I agree: one small pull request with a first concrete test is better than moving the whole mutation set. I will check which of the missed cases can be reached through PX4’s own MAVLink handling and not only through the upstream parser. For the first case I will write down the input condition, the expected PX4 behaviour and the assertion that would fail, and I will post it here before I open anything.

One question so I understand your side better: do you work on MAVLink tests for a product or a project, or is this more of a general interest for you? Both are fine, I would just like to know who would use such tests.

Best regards

Yannik

Hi Yannik,

Thank you for asking. It is directly relevant to our work rather than just a general interest.

I work with PAMILANGA LTD, where we are developing PAMIR ARGUS, an evidence and assurance framework for autonomous systems.

Our focus is on making system behaviour reconstructable, explainable and reproducible, particularly when sensor inputs, communication, estimation or control behaviour diverge from what was expected.

PX4 and MAVLink are relevant to this work because they provide concrete opportunities to study how input conditions propagate through a system and how the resulting behaviour can be verified.

We are not claiming to maintain a production MAVLink test suite within PX4. Our interest is in developing and evaluating reproducible validation methods, including targeted regression tests, fault injection, first observable divergence and traceable evidence.

So the potential users would include our own validation research and, where the tests are contributed upstream, PX4 developers and other projects that depend on reliable MAVLink handling.

I think your proposed approach is exactly right: identify a missed case that is observable through PX4’s own handling, define the expected behaviour and failing assertion, and discuss that specific case before opening a PR.

I would be happy to review the first proposed test from a reproducibility and evidence perspective when you post it.

Best regards,
Yiğitcan Öztürk
PAMILANGA LTD

Hi Yiğitcan, thank you for the clear answer. Here is the first concrete result, with limits. I ran two cases against the MAVLink header that PX4 builds (px4_sitl_cov, submodule 1b1e896a, clang 18.1.3, no sanitizer), original against a one line mutant, three runs each. Case 1: without a signing key, a MAVLink2 message must not carry the SIGNED flag and must be header plus payload plus 2 bytes long. The mutant sets the flag, the assertion fails in 3 of 3 runs, the original passes 3 of 3. Case 2: a frame with a truncated payload must have the missing payload bytes filled with zero. A mutant that fills with one fails 3 of 3, the original passes 3 of 3. Limits: this is the generated library header, not a full PX4 run. PX4 has no test today that feeds raw bytes into the parser, so I would like the maintainers to say where such a test belongs. I also withdraw my earlier idea about the length field: PX4 does not read it in the middle of a frame, so that case is not a PX4 behaviour test.

Best regards

Yannik

Hi Yannik,

Thank you for sharing the concrete results and, especially, for documenting their limits.

These are useful first regression cases. The original-versus-mutant comparisons provide clear evidence that the targeted assertions can detect the two introduced behavioural changes under the stated build configuration.

I also appreciate your decision to withdraw the earlier length-field case once you established that it was not testing an observable PX4 behaviour.

I think the key distinction now is between validating the MAVLink library header used by PX4 and validating PX4’s own MAVLink handling.

The two tests establish the former, but they do not yet demonstrate the latter.

For the next step, I would suggest keeping the existing library-level results as a reproducible baseline and asking the PX4 maintainers to identify the appropriate integration boundary for a raw-byte parser test.

Once that boundary is identified, a focused PX4 regression test could verify not only the parser result but also the observable behaviour of the consuming PX4 component.

For reproducibility, it would also be useful to preserve the exact test inputs, mutant definitions, assertions and six execution outcomes for each case.

This is a constructive progression from mutation analysis toward maintainable regression coverage.

I would support waiting for maintainer guidance on test placement before expanding the scope.

Best regards,
Yiğitcan Öztürk
PAMILANGA LTD

Hi Yigitcan,

thank you, that is a fair way to put it. I agree: the two cases cover the library header that PX4 builds, but they do not show how PX4 itself consumes raw bytes. I will keep the library level results as the baseline and wait for the maintainers’ view on where a raw byte parser test belongs before I add anything.

I keep the exact inputs, mutant definitions, assertions and the six outcomes (three original, three mutant) for each case, and I will link them in the manifest.

Best regards

Yannik

Hi Alexander, I read the abstract of your talk Fleet Scale Bug Hunting in PX4, including the hardware CI part. One question from a different angle: when a CI run passes, how do you know the tests would have failed if the code had a bug? I tried planting 40 small changes in the MAVLink parser, and the existing tests noticed 22 of them. Do you check test quality in some way, or is a green run the signal you rely on? Thanks for any thoughts.

Hi PX4 maintainers,

I would like to ask where a small test for raw byte MAVLink parsing would fit best in PX4.

What I measured so far: I planted 40 small changes in the MAVLink C library (c_library_v2, commit 56f6435e) and ran the tests with sanitizers. With this test corpus 22 of the 40 changes were noticed and 18 were not (the count depends on the corpus, an earlier run with a different corpus gave 21). All missed cases are documented in this thread and in my earlier one.

I then checked two cases against the PX4 header (px4_sitl_cov build, submodule 1b1e896a, clang 18.1.3): the handling of the SIGNED flag and a truncated payload. In both cases the planted change made the test fail in 3 of 3 runs, and the original code passed in 3 of 3 runs.

Limit: this tests the MAVLink library header used by PX4, not PX4’s own MAVLink handling in the modules.

Question: is there a preferred place in the PX4 test setup for a test that feeds raw bytes into the parser and checks the behaviour of the consuming component, or should it stay outside the repository? If it fits, I can send a small pull request with one or two tests. Yiğitcan Öztürk has kindly offered to review it.

Thanks for your time.
Yannik