Fix/PLT 406 param list clear function clears local parameter - #85
Open
jeanbaptistelab wants to merge 9 commits into
Open
Fix/PLT 406 param list clear function clears local parameter#85jeanbaptistelab wants to merge 9 commits into
jeanbaptistelab wants to merge 9 commits into
Conversation
jeanbaptistelab
requested review from
Copilot,
hendav76,
kivkiv12345 and
troelsjessen
July 24, 2026 08:51
There was a problem hiding this comment.
Pull request overview
Fixes PLT-406 by changing param_list_clear() semantics so it does not wipe “local” parameters that are dynamically added with node == 0 (e.g., CSH/APM-defined params), and adds a regression test to validate the behavior.
Changes:
- Update
param_list_clear()to only clear non-local (node != 0) entries from the dynamic list. - Add a new
plt_406test exercising the clear/remove behavior for node==0 vs node!=0 parameters. - Minor test/build updates (fix
plt_405exit code; register new test in Meson).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/plt_406.c | Adds a regression test covering PLT-406 behavior around param_list_clear() and parameter persistence. |
| tests/plt_405.c | Fixes test program to return success (0) on pass. |
| tests/meson.build | Registers the new plt_406 test executable. |
| src/param/list/param_list.c | Changes param_list_clear() to preserve node==0 list entries while clearing node!=0 entries. |
| meson.build | Simplifies dependency list selection for the param library build. |
Comments suppressed due to low confidence (1)
tests/plt_406.c:30
- Same as above: check the return value of
param_list_create_remotebefore using it.
remote = param_list_create_remote(128, 400, PARAM_TYPE_UINT16, PM_DEBUG, 0, "remote", NULL, NULL, -1);
param_list_add(remote);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+416
to
+420
| struct param_s *iter = 0; | ||
| SLIST_FOREACH(iter, ¶m_list_head, next) { | ||
| if(*iter->node != 0) { | ||
| SLIST_REMOVE(¶m_list_head, iter, param_s, next); | ||
| param_list_destroy(iter); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/param/list/param_list.c:421
param_list_clear()currently removes elements while iterating withSLIST_FOREACHand then callsparam_list_destroy()on a stack copy of the element. This can lead to use-after-free in the loop increment and can also attempt tofree()stack memory (becauseparam_list_destroy_impl()frees theparampointer itself in dynamic mode). Iterate safely by cachingnext, remove the real element, and destroy the real pointer.
SLIST_FOREACH(iter, ¶m_list_head, next) {
if(*iter->node != 0) {
SLIST_REMOVE(¶m_list_head, iter, param_s, next);
struct param_s to_be_destroyed = *iter;
param_list_destroy(&to_be_destroyed);
tests/plt_406.c:24
- This assertion checks
p(the previously found local param) instead ofremote. Ifparam_list_create_remote()fails,param_list_add(remote)will dereference NULL.
assert(p);
Comment on lines
+15
to
+18
| if(NULL == p) { | ||
| /* libparam is probably built as a shared library -> need to explicitly add our own parameters*/ | ||
| param_list_add((param_t *)&plt_406); | ||
| } |
| plt_405_exe = executable('plt_405', 'plt_405.c', dependencies: [param_dep, csp_dep]) | ||
| test('plt_405', plt_405_exe) No newline at end of file | ||
| test('plt_405', plt_405_exe) | ||
| plt_406_exe = executable('plt_406', 'plt_406.c', dependencies: [param_dep, csp_dep], link_args : ['-Wl,-Map=plt_406.map']) |
Comment on lines
+419
to
426
| while (iter_param) { | ||
| const param_t * param = iter_param; | ||
| if (i.phase != 0 && (i.element && *(i.element->node) != 0)) { | ||
| SLIST_REMOVE(¶m_list_head, param, param_s, next); | ||
| param_list_destroy(param); | ||
| } | ||
| iter_param = param_list_iterate(&i); | ||
| } |
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.
Local parameters (whose node == 0) are usually placed in a specific “param” ELF section and are read-only.
In module code, remote parameters are added to a linked list, independent of the of the read-only “param” ELF section.
However, in CSH context, APMs that define their own parameters, add those parameters to the linked-list during initialization (by calling param_list_add()). Those parameters are in essence local not remote (they are part of the CSH instance local parameters).
When some code calls the param_list_clear() function (for instance from hk_store.c, part of OBC House Keeping), the linked list is essentially reset, causing the list of CSH parameters to revert back to the list as it was before loading any APM.