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

Fix buffer overrun bug in CPU upsample op #1501

Merged
merged 1 commit into from
Jul 26, 2019
Merged

Fix buffer overrun bug in CPU upsample op #1501

merged 1 commit into from
Jul 26, 2019

Conversation

snnn
Copy link
Member

@snnn snnn commented Jul 25, 2019

Description:
Fix buffer overrun bug in CPU upsample op. Introduced in #1484
Motivation and Context

  • Why is this change required? What problem does it solve?
    A buffer overrun bug may cause application crash. (wrote more bytes than the buffer has)

  • If it fixes an open issue, please link to the issue here.

@snnn snnn requested a review from yufenglee July 25, 2019 21:13
@snnn snnn requested a review from a team as a code owner July 25, 2019 21:13
@@ -342,7 +342,7 @@ Status Upsample<T>::BaseCompute(OpKernelContext* context, const std::vector<floa
Tensor* Y = context->Output(0, Y_dims);

if (no_scale) {
memcpy(Y->MutableDataRaw(), X->DataRaw(), Y->Size() * sizeof(T));
memcpy(Y->MutableDataRaw(), X->DataRaw(), Y->Size());
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename Tensor::Size to Tensor::SizeInBytes in a separate PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we rename Tensor::Size to Tensor::SizeInBytes in a separate PR?

It comes with a cost. You know, it's a source code level break change. Many partners are using this class.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the fixing. Didn't know Size() returns byte size.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer making the names more explicit at the cost of possibly breaking some ongoing code. Otherwise, someone else would make the same mistake later and it's more expensive to debug and fix then.

Copy link
Member

Choose a reason for hiding this comment

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

Agree. Let me make the change in a separate PR.

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.

4 participants