Conversation
MSP_SDCARD_SUMMARY decides three lines earlier that no card is present, then calls sdcard_getMetadata() anyway. That returns NULL while sdcardVTable is unset, and the vtable is only bound when the card is actually wanted: when the blackbox device is SDCARD, or terrain is enabled. So the pointer is NULL on any board that has SD card support compiled in and does not use it, and on SITL launched without --sdcard. On a flight controller address zero is mapped, so the dereference returns four bytes of flash and the reported card size is nonsense that nobody reads when no card is fitted. A hosted build does not map address zero: SITL dies with SIGSEGV as soon as the Configurator opens the Blackbox tab, which is the only tab that asks for this.
Contributor
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR |
PR Summary by QodoGuard missing SD card metadata in MSP summaries
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happens
On
maintenance-10.x, SITL dies with SIGSEGV the moment the Configurator opens the Blackbox tab. That tab is the only one that asks forMSP_SDCARD_SUMMARY, and the request is what kills it.Reproduced on a clean
maintenance-10.x(be5b352) with no other changes, at-O2and at-O0, so it is not an optimiser artefact.Why
serializeSDCardSummaryReply()decides three lines earlier that no card is present, and then asks the card about itself anyway:sdcard_getMetadata()returns NULL whilesdcardVTableis unset, and the vtable is bound only when the card is actually wanted:So the pointer is NULL on any board that has SD card support compiled in and is not using it, which is the common case, and on SITL launched without
--sdcard.Why it has not been seen before
The line itself is old: it is the same in 9.1.0 and in
master. Two things kept it quiet.On a flight controller, address zero is mapped and readable, so the dereference returns four bytes of flash and the Configurator shows a nonsense card size in a field nobody reads when no card is fitted. Wrong, but harmless.
SITL did not compile this branch at all until d8c74f0,
feat(SITL): simulated SD card backed by a host image file (--sdcard), which addedUSE_SDCARDandUSE_SDCARD_SITLto the SITL target. Before that the#elsepath wrote five zeroes and touched no pointer. A hosted build does not map address zero, so from that commit onwards the same old defect is fatal rather than cosmetic.The change
Read the pointer once, and report zero blocks when there is no card driver, which is what the rest of the reply already says.
Testing
SITL on Windows, gcc 15.2, built from be5b352 with and without the patch. The requests the Blackbox tab sends, in the order it sends them:
MSP_FEATUREMSP_DATAFLASH_SUMMARYMSP_SDCARD_SUMMARYMSP2_COMMON_SETTING_INFOMSP2_COMMON_SETTINGMSP2_BLACKBOX_CONFIGWith the patch the Configurator's Blackbox tab opens against SITL and the simulator stays up.
On hardware the visible difference is the reported card size when no card is fitted: a random number before, zero after.