Skip to content

DAOS-18681 object: Fix potential memory leaks and error handling#17730

Open
wangshilong wants to merge 3 commits intomasterfrom
shilongw/DAOS-18681-1
Open

DAOS-18681 object: Fix potential memory leaks and error handling#17730
wangshilong wants to merge 3 commits intomasterfrom
shilongw/DAOS-18681-1

Conversation

@wangshilong
Copy link
Contributor

This patch fixes several resource-handling bugs that could lead to memory leaks or crashes(all catched by AI):

1.Avoid leaking memory allocated in tse_task_cb() when tse_task_reinit_with_delay() fails by introducing a helper to clean up on failure.
2. Ensure sub_anchors_free() is called on error paths for enumeration and key2anchor case.
3. Invoke dc_tx_local_close() on error paths to properly close local transactions.
4. Make drpc_call() return an error when allocation fails to avoid potential NULL dereference and segfault.

Steps for the author:

  • Commit message follows the guidelines.
  • Appropriate Features or Test-tag pragmas were used.
  • Appropriate Functional Test Stages were run.
  • At least two positive code reviews including at least one code owner from each category referenced in the PR.
  • Testing is complete. If necessary, forced-landing label added and a reason added in a comment.

After all prior steps are complete:

  • Gatekeeper requested (daos-gatekeeper added as a reviewer).

This patch fixes several resource-handling bugs that could lead to
memory leaks or crashes(all catched by AI):

1.Avoid leaking memory allocated in tse_task_cb() when tse_task_reinit_with_delay()
fails by introducing a helper to clean up on failure.
2. Ensure sub_anchors_free() is called on error paths for enumeration and key2anchor case.
3. Invoke dc_tx_local_close() on error paths to properly close local transactions.
4. Make drpc_call() return an error when allocation fails to avoid potential
NULL dereference and segfault.

Signed-off-by: Wang Shilong <shilong.wang@hpe.com>
@wangshilong wangshilong requested review from a team as code owners March 18, 2026 14:23
@github-actions
Copy link

Ticket title is 'Fix potential memory Leaks '
Status is 'Open'
https://daosio.atlassian.net/browse/DAOS-18681

Nasf-Fan
Nasf-Fan previously approved these changes Mar 18, 2026
NiuYawei
NiuYawei previously approved these changes Mar 19, 2026
if (comp_cb && !rc)
rc = register_cb(task, true, comp_cb, comp_data,
comp_data_size);
rc = register_cb(task, true, comp_cb, comp_data, comp_data_size, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Looks this function could be used to register two callbacks, shouldn't we free the first one when the second registration failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this should be fixed as well.

Signed-off-by: Wang Shilong <shilong.wang@hpe.com>
@wangshilong wangshilong dismissed stale reviews from NiuYawei and Nasf-Fan via 4617022 March 19, 2026 04:13
@daosbuild3
Copy link
Collaborator

Test stage Functional on EL 9 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos/job/PR-17730/1/display/redirect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants