ZhengweiZhu commented on PR #3447:
URL: https://github.com/apache/brpc/pull/3447#issuecomment-5295645437

   Thanks for investigating this. I reached a different conclusion after 
tracing the lifetime in the failing tests.
   
   The reported allocations are the root client spans submitted to the 
asynchronous bvar collector. `Controller::Reset` / `Controller::SubmitSpan` 
clears `Controller::_span`, but the collector can retain its reference until 
the next collection cycle. The short-lived unit-test binary may exit before 
that happens, so LeakSanitizer reports the still-pending span allocations.
   
   Because the failure is caused by asynchronous test teardown, I think the fix 
should be scoped to the tests rather than suppressing LeakSanitizer for every 
allocation made by `CreateClientSpan`, `CreateBthreadSpan`, and 
`CreateServerSpan`. A factory-wide `ANNOTATE_SCOPED_MEMORY_LEAK` also risks 
hiding genuine leaks in those paths.
   
   I opened #3448 with a narrower approach: after `Reset` and `SubmitSpan`, the 
tests wait with a bounded deadline for their existing `weak_ptr` to expire. 
This:
   
   - verifies the intended lifetime contract instead of merely suppressing the 
report;
   - avoids a fixed sleep;
   - preserves LeakSanitizer coverage for the span factory paths;
   - fails explicitly if the collector does not release the span within the 
deadline.
   
   PR: https://github.com/apache/brpc/pull/3448


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to