Repository navigation
Fix COM connection-point cookie lifetime ownership - #135651
AaronRobinsonMSFT with Copilot wants to merge 3 commits into
Conversation
|
Azure Pipelines: 16 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
Co-authored-by: AaronRobinsonMSFT <[email protected]>
| while (pCookie != nullptr && pCookie->m_id < m_NextCookieId) | ||
| pCookie = CONNECTIONCOOKIELIST::GetNext(pCookie); |
There was a problem hiding this comment.
@copilot This is a linear lookup. Is this introducing a performance issue that could create a performance cliff?
There was a problem hiding this comment.
Yes. Rescanning from the head per item made a full traversal O(n²), including bulk Next and Skip. Fixed in 84c89c7 with a version-validated next-node cache: unchanged traversal is O(n) overall. Insert/unlink invalidates the cache under the lock before it can be dereferenced; recovery rescans by ID in O(n). Repeated mutations between items can still incur repeated scans.
Added coverage for bulk/single Next, multi-item Skip, and cloning valid/invalidated cursors. Linux builds passed, but this runner cannot compile/run Windows COM tests or measure their timings; the complexity improvement is source-derived, not benchmarked.
Co-authored-by: AaronRobinsonMSFT <[email protected]>
Unadvisecould delete a still-linked cookie when managed removal threw, or create multiple deleting owners during concurrent or reentrant removal. Publication and enumeration also exposed cookie pointers beyond their protected lifetime.CrstInterop; release remaining cookies at teardown.