fix mock NMR deregister race. - #319
Conversation
2d4b365 to
7d63080
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6e257781-cd5a-4ae3-9943-0c217ccad54e
7d63080 to
d87efd1
Compare
| should_begin_unbind = binding_ptr->client.deregistering || binding_ptr->provider.deregistering; | ||
| l.unlock(); | ||
| if (should_begin_unbind) { | ||
| (void)begin_unbind(*binding_ptr); |
There was a problem hiding this comment.
This new call can expose a duplicate-completion bug in begin_unbind(). If both detach callbacks return STATUS_PENDING and their completion routines race before begin_unbind() reacquires the lock, the second completion can call unbind_complete() and erase the binding. This begin_unbind() call can then also observe both sides complete and call unbind_complete() again, causing duplicate cleanup callbacks and double-decrementing binding_count. I checked the lifetime angle: the caller retains a shared_ptr, so this is not a use-after-free, but the duplicate cleanup/reference accounting remains. NMR permits each pending detach to complete independently.
|
|
||
| NTSTATUS deregister_status = NmrDeregisterProvider(nmr_provider_handle); | ||
| if (deregister_status == STATUS_PENDING) { | ||
| (void)NmrWaitForProviderDeregisterComplete(nmr_provider_handle); |
There was a problem hiding this comment.
This smoke test does not validate the wait result. If NmrWaitForProviderDeregisterComplete() fails, the test silently continues and can pass with a live registration or incomplete detach; the client-side wait below has the same issue. Also, the test only relies on probabilistic overlap and does not force deregistration during ClientAttachProvider, so it may miss the race this PR targets.
Summary
Testing