Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep-copy the process bundle descriptor when creating a new bundle processor. #29742

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

tvalentyn
Copy link
Contributor

@tvalentyn tvalentyn commented Dec 13, 2023

After protobuf v4 upgrade we are seeing SDK crashes in #27330 .

A possible reason might be that micro-protobuf protos objects are more sensitive to unsafe concurrent modifications, leading to process memory corruption.

This change should reduce the risk of concurrent modifications.

@tvalentyn
Copy link
Contributor Author

R: @scwhittle

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

# Reduce risks of concurrent modifications of the same protos
# captured in bundle descriptor when the same bundle desciptor is used
# in different instructions.
copy.deepcopy(self.fns[bundle_descriptor_id]),
self.state_handler_factory.create_state_handler(
self.fns[bundle_descriptor_id].state_api_service_descriptor),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the deepcopied descriptor_id here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, that shouldn't hurt and would be cleaner.

# Reduce risks of concurrent modifications of the same protos
# captured in bundle descriptor when the same bundle desciptor is used
# in different instructions.
copy.deepcopy(self.fns[bundle_descriptor_id]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it would be safer to use Message generated CopyFrom method instead. Unclear to me if deepcopy would do something odd with lower-level upb impl.
deepcopy isn't mentioned here https://protobuf.dev/reference/python/python-generated/

Copy link
Contributor Author

@tvalentyn tvalentyn Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tvalentyn
Copy link
Contributor Author

thanks, @scwhittle , PTAL.

Copy link
Contributor

@scwhittle scwhittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Hope this works :)

@tvalentyn
Copy link
Contributor Author

LGTM, thanks! Hope this works :)

fingers crossed but early results are encouraging.

@tvalentyn tvalentyn merged commit 8672028 into apache:master Dec 13, 2023
72 checks passed
@tvalentyn tvalentyn deleted the deepcopy_descriptors branch December 13, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants