walterzhaoJR opened a new pull request, #3244: URL: https://github.com/apache/brpc/pull/3244
release_tls_block() and release_tls_block_chain() do not guard against a block being returned to TLS when it is already the list head. The assignment `b->portal_next = block_head` becomes `b->portal_next = b`, forming a self-loop that causes remove_tls_block_chain() or share_tls_block() to spin forever, silently hanging the thread at exit. Fix: - release_tls_block(): add early return when b == block_head, skipping the duplicate insertion. - release_tls_block_chain(): during the existing chain walk, check each node against block_head before linking. Return early if overlap is detected so that num_blocks stays consistent with the actual list length (remove_tls_block_chain verifies this via CHECK_EQ). Add three unit tests that reproduce the self-loop through: 1. Direct double release_tls_block() of the same block. 2. release_tls_block_chain() with a chain overlapping the TLS head. 3. IOBufAsZeroCopyOutputStream::BackUp() followed by a second release. ### What problem does this PR solve? Issue Number: resolve Problem Summary: ### What is changed and the side effects? Changed: Side effects: - Performance effects: - Breaking backward compatibility: --- ### 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]
