Repository navigation
Conversation
|
Ticket title is 'RPCs can outlive group detach without holding a group reference' |
5107e6b to
e01ec68
Compare
bf79fee to
97a8bd4
Compare
b039af7 to
d341064
Compare
|
This branch picked up more work since it was first posted. The drain reordering itself held up, but further runs of the same reproducer (init, four worker threads issuing synchronous ev==NULL array/dfs I/O with injected errors, teardown without joining the workers, 50 cycles) kept surfacing races in the drain paths. Each fix below is grounded in a reproduced trace; in brief:
With these on top, the reproducer completes consecutive 50-cycle runs cleanly, where the first posted revision still aborted within tens of cycles. Happy to split anything out if that is easier to review. |
d341064 to
13fd77e
Compare
|
The broadened drain-race work moved to #19542, and the scope here is narrowed back to the CaRT group reference piece, tracked in DAOS-19995. Following the review on DAOS-19955, I understand the overlap this PR tried to harden against as outside the API: once dfs_disconnect() and dfs_release() return, workers still inside dfs_read/dfs_write are operating on freed objects, and no reordering of the scheduler internals can make that safe. A no-overlap variant of the reproducer, with the workers joined before teardown, also completed two 500-cycle runs against a master build with #19542 without a crash, hang, or assert, so I have not found a crash with no DAOS call in flight across teardown. Rather than opening a new pull request, I reopened this one with the CaRT group reference piece, crt_corpc_req_create() taking a group reference when assigning crp_grp_priv so it pairs with the decref in crt_rpc_priv_free(), now with a test case. |
13fd77e to
ca71e54
Compare
|
/run-ci |
|
Test stage Functional on EL 9 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-19526/1/testReport/ |
An RPC stores its group in rpc_priv->crp_grp_priv without taking a reference, at every site that assigns the field. crt_rpc_priv_free() releases no group reference either, so the reference the RPC relies on is the caller's attach reference. Once crt_group_detach() drops that reference and the count reaches zero, an RPC that is still alive - for example a request aborted during context teardown whose completion is processed after the caller has returned - dereferences the freed group in crt_rpc_priv_free() and in the timeout and completion paths that read group state. Take a group reference wherever crp_grp_priv is assigned: crt_req_create(), crt_req_create_internal() and the collective root path in crt_corpc_req_create(). Release it in crt_rpc_priv_free(). crt_req_set_endpoint() replaces the group, so release the previous reference there before taking the new one. Fixes: DAOS-19995 Signed-off-by: Jihyeon Gim <potatogim@gluesys.com>
Cover the fix that has an RPC hold a reference on its group: rank 0 creates a secondary group, sends an RPC on it, and destroys the secondary group while the RPC is still in flight, so the completion and crt_rpc_priv_free() run after the last external reference on the group is gone. Without the fix this is a use-after-free on crp_grp_priv. The test runs two crt_launch instances on one node through the grp_lifetime avocado test, following the corpc_errors pattern. Fixes: DAOS-19995 Signed-off-by: Jihyeon Gim <potatogim@gluesys.com>
Format no_pmix_grp_lifetime.c with the repository clang-format settings, and use the "(C) Copyright <year> <organization>" form in the two new test files. Add Gluesys to the spelling dictionary so pylint accepts it in the docstring. Signed-off-by: Jihyeon Gim <potatogim@gluesys.com>
e52317a to
ae1ff3c
Compare
|
Added #19584 to run these changes through CI |
Drop the copied host-name comment, use plain keys for the single hosts and tests variants, and run the test in daily regression instead of on every PR. Signed-off-by: Jihyeon Gim <potatogim@gluesys.com>
Fixes DAOS-19995
Reopening with the scope narrowed to the CaRT group reference piece per the review discussion. The drain reordering work from the original branch moved to #19542, and the follow-up ticket DAOS-19995 now tracks the group reference defect separately, as noted when I closed this.
crt_corpc_req_create() and the other sites assigning crp_grp_priv take a group reference when the field is set, so it pairs with the decref in crt_rpc_priv_free(). Without that, an RPC can outlive the group it points at: the uri and address lookups on send and the completion path dereference the group after its last external reference is gone.
This comes with a test case as promised: a new cart functional test, no_pmix_grp_lifetime, runs two crt_launch instances on one node through the grp_lifetime avocado test, following the corpc_errors pattern. Rank 0 creates a secondary group, creates an RPC on it, then destroys the secondary group to drop the last external reference before sending, so the send lookups, the completion, and crt_rpc_priv_free() all run after the group lifetime would otherwise end.
Locally, with the fix reverted the test under valgrind reports invalid reads in crt_grp_priv_get_primary_rank from crt_req_send on a block freed by crt_group_secondary_destroy, and exits 139. With the fix in place the same test completes and valgrind reports no invalid accesses.
The CaRT changes here are the same sixteen lines from the earlier revision that frostedcmos already reviewed.
Steps for the author:
After all prior steps are complete: