Skip to content

Destroy handle_ in ~KafkaHandleBase body to fix use-after-dtor - #324

Open
makxenov wants to merge 1 commit into
mfontanini:masterfrom
makxenov:fix-kafka-handle-base-destroy-in-dtor-body
Open

Destroy handle_ in ~KafkaHandleBase body to fix use-after-dtor#324
makxenov wants to merge 1 commit into
mfontanini:masterfrom
makxenov:fix-kafka-handle-base-destroy-in-dtor-body

Conversation

@makxenov

Copy link
Copy Markdown

handle_ is a unique_ptr whose HandleDeleter reads destroy_flags_ back through the owning KafkaHandleBase when it runs. With a defaulted destructor, member destruction is member-wise: the trivial fields (including destroy_flags_) are destroyed before handle_, so the deleter reads them afterwards. Under MSan -fsanitize-memory-use-after-dtor that destruction poisons the fields, turning the read into a use-after-destructor.

Reset handle_ explicitly in the destructor body, while the object -- and destroy_flags_ -- is still fully alive.

handle_ is a unique_ptr whose HandleDeleter reads destroy_flags_ back through
the owning KafkaHandleBase when it runs. With a defaulted destructor, member
destruction is member-wise: the trivial fields (including destroy_flags_) are
destroyed before handle_, so the deleter reads them afterwards. Under MSan
-fsanitize-memory-use-after-dtor that destruction poisons the fields, turning
the read into a use-after-destructor.

Reset handle_ explicitly in the destructor body, while the object -- and
destroy_flags_ -- is still fully alive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant