Skip to content

[binder] Clean up parcel interfaces#27322

Merged
TaWeiTu merged 2 commits intogrpc:masterfrom
TaWeiTu:cleanup-parcel-interface
Sep 14, 2021
Merged

[binder] Clean up parcel interfaces#27322
TaWeiTu merged 2 commits intogrpc:masterfrom
TaWeiTu:cleanup-parcel-interface

Conversation

@TaWeiTu
Copy link
Copy Markdown
Contributor

@TaWeiTu TaWeiTu commented Sep 11, 2021

Some changes:

  • OnTransactCb now takes a non-const ReadableParcel* so that testing
    codes no longer have to rely on mutable.
  • Remove GetReadableParcel() interface from binder since we only send
    one-way transaction and the output (readable) parcel is never used.
  • Remove GetDataPosition() / SetDataPosition() interfaces since they are
    both unused.

@TaWeiTu TaWeiTu added the release notes: no Indicates if PR should not be in release notes label Sep 11, 2021
@TaWeiTu TaWeiTu requested a review from sifmelcara September 11, 2021 10:29
@TaWeiTu TaWeiTu force-pushed the cleanup-parcel-interface branch 2 times, most recently from ce64eef to fc46e6f Compare September 11, 2021 15:48
AParcel* unused_output_parcel;
return AIBinder_transact(binder, static_cast<transaction_code_t>(tx_code),
&input_parcel_->parcel_, &output_parcel_->parcel_,
&input_parcel_->parcel_, &unused_output_parcel,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oops, I think we leak memory here? We will need to call AParcel_delete to delete the output parcel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How come we didn't notice this leak before?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(I mean, it is my fault that in my first prototype I didn't do any memory management and leaves no TODO)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right. I guess we weren't building Android code with Sanitizers before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it even possible to detect leak on Android?

Quick google search shows https://source.android.com/devices/tech/debug/hwasan but I'm not sure how effective it is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@TaWeiTu TaWeiTu force-pushed the cleanup-parcel-interface branch 2 times, most recently from 41995b7 to 3417f17 Compare September 13, 2021 02:50
Some changes:

* OnTransactCb now takes a non-const ReadableParcel* so that testing
  codes no longer have to rely on mutable.
* Remove GetReadableParcel() interface from binder since we only sent
  one-way transaction and the output (readable) parcel is never used.
* Remove GetDataPosition() / SetDataPosition() interfaces since they are
  both unused.
* Some changes that should've been made to grpc#27257 but was somehow
  missing...
@TaWeiTu TaWeiTu force-pushed the cleanup-parcel-interface branch from 3417f17 to 8e1100d Compare September 14, 2021 03:42
@TaWeiTu
Copy link
Copy Markdown
Contributor Author

TaWeiTu commented Sep 14, 2021

@sifmelcara Can you take a look at this? Thanks!

Copy link
Copy Markdown
Contributor

@sifmelcara sifmelcara left a comment

Choose a reason for hiding this comment

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

Android CI failed although it looks unrelated to this change but we probably want to rerun in just to be safe

@TaWeiTu
Copy link
Copy Markdown
Contributor Author

TaWeiTu commented Sep 14, 2021

Android CI passed, so I will just enable auto-merge.

@TaWeiTu TaWeiTu enabled auto-merge (squash) September 14, 2021 06:15
@TaWeiTu TaWeiTu merged commit 8d5b93e into grpc:master Sep 14, 2021
lidizheng pushed a commit to lidizheng/grpc that referenced this pull request Sep 23, 2021
Some changes:

* OnTransactCb now takes a non-const ReadableParcel* so that testing
  codes no longer have to rely on mutable.
* Remove GetReadableParcel() interface from binder since we only sent
  one-way transaction and the output (readable) parcel is never used.
* Remove GetDataPosition() / SetDataPosition() interfaces since they are
  both unused.
* Some changes that should've been made to grpc#27257 but was somehow
  missing...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang/core release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants