bobhan1 opened a new pull request, #3522: URL: https://github.com/apache/brpc/pull/3522
### What problem does this PR solve? Issue Number: resolve #3520 Problem Summary: `bvar::detail::AgentGroup` directly accesses the raw `_s_tls_blocks` thread-local variable from inline functions. When a bthread suspends and resumes on another pthread, Clang may reuse the TLS address resolved for the previous pthread. This can make bvar access another pthread's agent vector and race with its initialization or resize. ### What is changed and the side effects? Changed: - Declare `_s_tls_blocks` with the existing static-member volatile TLS accessor mechanism. - Resolve the current pthread's TLS block vector once in each AgentGroup operation and consistently use that pointer. - Route TLS initialization and cleanup writes through the existing setter accessor. Side effects: - Performance effects: On compiler targets where volatile TLS access is enabled, AgentGroup operations use the existing noinline TLS accessor to prevent the TLS address from being retained across a bthread suspend point. Other targets retain direct TLS access through the existing macros. - Breaking backward compatibility: None. --- ### Check List: - Please make sure your changes are compilable. - When providing us with a new feature, it is best to add related tests. - Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md). -- 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]
