Repository navigation
Check that commands, events, parameters, and telemetry fit in framework buffers - #1186
Closed
Dev-next-gen wants to merge 1 commit into
Closed
Dev-next-gen wants to merge 1 commit into
Dev-next-gen wants to merge 1 commit into
Conversation
…rk buffers F Prime serializes command arguments, event arguments, parameter values, and telemetry values into fixed-size buffers (FW_CMD_ARG_BUFFER_MAX_SIZE, FW_LOG_BUFFER_MAX_SIZE, FW_PARAM_BUFFER_MAX_SIZE, FW_TLM_BUFFER_MAX_SIZE). When a definition does not fit, the model passes every check, the C++ compiles, and the generated code fails an FW_ASSERT at run time, or the command cannot be carried at all. See nasa#679. These buffer sizes are now framework constants, so the analyzer can check them. When a buffer size constant is defined, check that the minimum serialized size of each command's parameters, each event's parameters, each parameter, and each telemetry channel fits in the buffer. The minimum size counts every string as empty, so the check reports an error only when no value can fit. A model in which some values fit and others do not, which F Prime handles at run time, is still valid; in particular the default F Prime configuration passes. In an F Prime build, each module is analyzed with only its dependencies. Make commands, events, parameters, and telemetry channels depend on the buffer size constants when they have location specifiers, so the check runs there too. The constants stay optional: a model that does not define them is not checked.
Collaborator
|
@Dev-next-gen Thank you for submitting this PR. This is a feature we would like to have, but it is not in our plan for the next FPP release. The issues we are currently working on are here: https://github.com/nasa/fpp/milestone/17 I'll close the PR for now, but we will keep it in mind when we are planning the release after next. |
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.
Change Description
When the model defines
FW_CMD_ARG_BUFFER_MAX_SIZE,FW_LOG_BUFFER_MAX_SIZE,FW_PARAM_BUFFER_MAX_SIZE, orFW_TLM_BUFFER_MAX_SIZE,fpp-checknow checks that the parameters of each command, the parameters of each event, the value of each parameter, and the value of each telemetry channel can fit in the corresponding buffer. The check uses the minimum serialized size, in which every string is empty, so it reports an error only when no value can fit. The constants stay optional: a model that does not define them is not checked.In an F Prime build each module is analyzed with only its dependencies, so commands, events, parameters, and telemetry channels now depend on the buffer size constants when those have location specifiers. Without this, the check would never run in a real F Prime build.
The new check is
CheckFrameworkBufferSizes, called fromCheckComponentDefs, with a newSerializedSizeTooLargeerror. The spec gains a "Buffer Sizes" section under framework definitions, each of the four specifier pages links to it, and the user's guide has a short example.Rationale
#679 asks for FPP to fail the build when a definition does not fit in the buffers F Prime uses to carry it. Today such a model passes every check, the C++ compiles, and the generated code asserts at run time. I measured this on F Prime itself (framework plus
Ref) withFW_COM_BUFFER_MAX_SIZE = 128:fpp-checkaccepts the model, and theCfdpManagerunit tests stop onAssert: ".../CfdpManagerComponentAc.cpp:12371". With this change,fpp-checkrejects that configuration with a single error,value of telemetry channel ChannelTelemetry: at least 232 bytes are required, but FW_TLM_BUFFER_MAX_SIZE is 122 bytes.I used the minimum size rather than the maximum on purpose. My first version counted strings at their maximum size, and it rejected the default F Prime configuration (for example the
OpenChipevent ofLinuxGpioDriver, which has three strings), even though that configuration works. With the minimum size, F Prime with the default configuration and withFW_COM_BUFFER_MAX_SIZE = 256passes with no error.Testing/Review Recommendations
fpp-checkcases underevent,command,param, andtlm_channel: for each kind, one at exactly the limit that passes and one over it that fails, plus an event whose struct argument has a string member.fpp-dependcase,framework_buffer_sizes, checks the new dependencies.fpp-checkandfpp-dependsuites andsbt test(716 tests) pass, and the existing reference outputs are unchanged.fpp-checkand the unmodified one on the F Prime framework plusRefwithFW_COM_BUFFER_MAX_SIZEset to 512, 256, and 128: no difference at 512 and 256, and the single error above at 128.FwSizeStoreTypelength only, including strings inside structs and arrays, because F Prime serializes a string with its actual length.Future Work
A warning, or an option, for definitions whose maximum size exceeds the buffer could follow if missions find it useful. I left it out so that the check never rejects a configuration that works.
AI Usage (see policy)
Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.
Refdeployment. That run showed that the first version rejected the default configuration, which led to the minimum-size rule."Nothing this pipeline produces is submitted without human approval. The entire pull request — the code change, the tests, the documentation updates and this description — was reviewed by a human before the pipeline was allowed to submit it."
(@Dev-next-gen)