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

Mandate static string for host and method passed to grpc_channel_register #19263

Merged
merged 1 commit into from
Aug 12, 2019

Conversation

soheilhy
Copy link
Contributor

@soheilhy soheilhy commented Jun 6, 2019

This is the implementation of grpc/proposal#148

It requires a major version bump.

@soheilhy soheilhy requested review from yashykt and vjpai June 6, 2019 03:38
@soheilhy soheilhy added the release notes: yes Indicates if PR needs to be in release notes label Jun 6, 2019
rc->path = grpc_mdelem_from_slices(
GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string(method)));
rc->path = grpc_mdelem_from_slices(GRPC_MDSTR_PATH,
Copy link
Member

Choose a reason for hiding this comment

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

I am worried that we might end up using the slices beyond the lifetime of the channel. Since we aren't explicitly requiring static strings that might end up leading to hard to debug use-after-free bugs

Copy link
Contributor

Choose a reason for hiding this comment

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

Right now, when the channel is done, it unrefs the slices, right?
Which implies that if someone manages to use it after the channel is done, then it had called ref before the channel called unref, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arjunroy good point, but I think @yashykt means even if they have reffed it, it would be a noop and deleted after the channel.

That's a legit concern because channels die frequently. I'll update the comment and will mention static.

Copy link
Contributor

Choose a reason for hiding this comment

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

A possible compromise, then, would be to use grpc_slice_from_copied_string? That I believe gives us a malloc'd, refcounted slice.

Copy link
Contributor

Choose a reason for hiding this comment

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

(We'd be doing more atomics than the static_string() case, but we'd still win out by not needing to go through the relatively heavy handed intern implementation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are changing the API via gRFC to make this static string. I don't think we need any extra copies or allocations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@vjpai
Copy link
Member

vjpai commented Aug 9, 2019

Where's the major version bump?

@soheilhy
Copy link
Contributor Author

soheilhy commented Aug 9, 2019

Apologies @vjpai I wasn't aware of the major version bump process. I updated the PR. Could you PTAL? Thanks!

@soheilhy soheilhy force-pushed the core-static-method branch 2 times, most recently from 5cd0511 to 318a580 Compare August 9, 2019 18:57
@@ -30,6 +30,9 @@

// Add this to a class that want to use Delete(), but has a private or
// protected destructor.
// Should not be used in new code.
// TODO(juanlishen): Remove this macro, and instead comment that the public dtor
// should not be used directly.
Copy link
Member

Choose a reason for hiding this comment

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

How did these get into this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for catching this, but I can't find this in my commit locally. It's weird.

I pull+rebased again and it looks gone now.

…ster_call

This is for the gRFC being prepared.

Bump the major version of core to 8.0.0.
@soheilhy
Copy link
Contributor Author

Thanks for the approval!

@soheilhy
Copy link
Contributor Author

Known issue #19819

@soheilhy soheilhy merged commit 834f0c7 into grpc:master Aug 12, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang/core release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants