-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
@@ -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()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.