Skip to content

Fix UB in CPU_tensor_apply#13121

Closed
zou3519 wants to merge 1 commit intopytorch:masterfrom
zou3519:fix-cpuapply-ub
Closed

Fix UB in CPU_tensor_apply#13121
zou3519 wants to merge 1 commit intopytorch:masterfrom
zou3519:fix-cpuapply-ub

Conversation

@zou3519
Copy link
Copy Markdown
Contributor

@zou3519 zou3519 commented Oct 25, 2018

std::memcpy has UB when either of src or dest are NULL, even if length
is 0. This can and does happen when the input tensors are scalar tensors.

This triggered UBSAN on #12824 but it is strange that it has not
been triggered before.

Test Plan: wait for tests

std::memcpy has UB when either of src or dest are NULL, even if length
is 0. This can and does happen when the input tensors are scalar tensors.

This triggered UBSAN on pytorch#12824 but it is strange that it has not
been triggered before.

Test Plan: wait for tests
Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Oct 25, 2018
Summary:
std::memcpy has UB when either of src or dest are NULL, even if length
is 0. This can and does happen when the input tensors are scalar tensors.

This triggered UBSAN on #12824 but it is strange that it has not
been triggered before.
Pull Request resolved: pytorch/pytorch#13121

Differential Revision: D10853113

Pulled By: zou3519

fbshipit-source-id: c4b4ad5e41de6f73dc755e0c25bc9947576a742d
@ezyang ezyang added the merged label Jun 25, 2019
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
std::memcpy has UB when either of src or dest are NULL, even if length
is 0. This can and does happen when the input tensors are scalar tensors.

This triggered UBSAN on pytorch#12824 but it is strange that it has not
been triggered before.
Pull Request resolved: pytorch#13121

Differential Revision: D10853113

Pulled By: zou3519

fbshipit-source-id: c4b4ad5e41de6f73dc755e0c25bc9947576a742d
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