Skip to content

Make MessageLite + Message destructors protected when custom VTable is on.#28323

Draft
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_941519116
Draft

Make MessageLite + Message destructors protected when custom VTable is on.#28323
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_941519116

Conversation

@copybara-service

Copy link
Copy Markdown

Make MessageLite + Message destructors protected when custom VTable is on.

The custom vtable experiment changes the MessageLite destructor from virtual to a no-op. Calling it directly outside of protobuf will not behave consistently before/after this experiment, so it should be hidden.

This will catch code that calls ~MessageLite() directly on a buffer, which could cause memory leaks if custom VTable is enabled.

Custom VTable is only available with destroying deletes, and destroying deletes forward delete my_message_ptr to the destroying delete operator. With VTable disabled, there is no destroying delete operator, and the MessageLite virtual destructor is called instead, so we can only hide these destructors with custom VTable on.

…able is on.

The custom vtable experiment changes the `MessageLite` destructor from virtual to a no-op. Calling it directly outside of protobuf will not behave consistently before/after this experiment, so it should be hidden.

This will catch code that calls `~MessageLite()` directly on a buffer, which could cause memory leaks if custom VTable is enabled.

Custom VTable is only available with destroying deletes, and destroying deletes forward `delete my_message_ptr` to the destroying delete operator. With VTable disabled, there is no destroying delete operator, and the `MessageLite` virtual destructor is called instead, so we can only hide these destructors with custom VTable on.

PiperOrigin-RevId: 941519116
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