Repository navigation
fix(tbl): close file descriptor after table load command - #2830
Closed
philphauler wants to merge 1 commit into
Closed
philphauler wants to merge 1 commit into
philphauler wants to merge 1 commit into
Conversation
CFE_TBL_LoadCmd opens a file via TxnOpenTableLoadFile but never closes it; TxnFinish only releases the registry lock. Every load command leaks one OS file descriptor, eventually exhausting the OSAL file table. Close the file inside the open-success block, the way CFE_TBL_LoadFromFile already does with the same helper. The descriptor exported on a failed open is not to be trusted (the OSAL stub hands back a fake id), so no close is attempted there. Tests assert OS_close is called once after a successful load and after a failure that follows the open, and not at all when the open fails.
philphauler
force-pushed
the
fix-2811-tbl-fd-leak
branch
from
September 5, 2026 20:55
f8a1345 to
6fc75a1
Compare
Contributor
Author
|
Hi @jphickey 👋 thanks for confirming the bug on #2811 and for the test guidance. Moved the close inside the open-success block (the OSAL stub hands back a fake id on a failed open, which is what CI tripped on) and added OS_close stub-count asserts on the three paths that open the file (6fc75a1). coverage-tbl-ALL passes. If #2774 is the one you would rather take, happy to close this one. Have a great day! |
Contributor
Author
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.
Checklist (Please check before submitting)
Describe the contribution
Fixes #2811. In
CFE_TBL_LoadCmd()the file descriptor fromCFE_FS_OpenFileForReading()was never closed on any path. The descriptor is now closed inside the open-success block onceCFE_TBL_SetMetaDataFromFileHeader()has consumed the header, the same shapeCFE_TBL_LoadFromFileuses.Testing performed
tbl_ut_load.caddsUtAssert_STUB_COUNT(OS_close, n)on each path that opens the file (per the note on #2811). The close sits inside the open-success block, likeCFE_TBL_LoadFromFile, because the OSAL stub hands back a fake object id on a forced open failure (this is what the first CI run tripped on). Run locally in the cFS dev bundle with the tests kept andcfe_tbl_task_cmds.creverted to dev: the two success-path asserts fail withCallCount: OS_close() (0) == 1(tbl_ut_load.c:323 and :370) and the failed-open path stays at 0 as it should. With the fix, coverage-tbl-ALL passes 1361/1361.Expected behavior changes
Table load commands no longer leak the opened file descriptor. Repeated table loads no longer accumulate leaked descriptors.
System(s) tested on
Hardware: x86_64 (WSL2), OS: Ubuntu 22.04, Versions: cFE dev 2612eb0 with OSAL and PSP from the cFS dev bundle, native build with ENABLE_UNIT_TESTS
Contributor Info
Filip Koscak - phil.phaulre@gmail.com