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 access to unitialized memory in VSX vector functions #89833

Closed
wants to merge 1 commit into from

Conversation

Flamefire
Copy link
Collaborator

@Flamefire Flamefire commented Nov 29, 2022

This results in e.g. failures in TestNNDeviceTypeCPU.test_groupnorm_nhwc_cpu_float32

So simply initialize the stack array with zeroes as expected and done in other implementations

Fixes #32502

cc @VitalyFedyunin @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 29, 2022

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/89833

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 215ba85:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions github-actions bot added the module: cpu CPU specific problem (e.g., perf, algorithm) label Nov 29, 2022
@drisspg drisspg added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Dec 1, 2022
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

a test would be nice

@ezyang
Copy link
Contributor

ezyang commented Dec 1, 2022

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Dec 1, 2022
@ezyang ezyang added the topic: bug fixes topic category label Dec 1, 2022
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 2 additional jobs have failed, first few of them are: trunk ,trunk / cuda11.6-py3.10-gcc7-sm86 / test (default, 4, 4, linux.g5.4xlarge.nvidia.gpu)

Details for Dev Infra team Raised by workflow job

@Flamefire
Copy link
Collaborator Author

a test would be nice

I'd normally agree but you cannot test for undefined behavior although UBSAN or valgrind may catch this if run on PPC.

It may be possible to add tests for loadu for all datatypes with different load sizes and assert the "not loaded" parts are zero but again they may succeed if the "stack garbage" happens to contain the correct values. I'm also not sure where to add such a test, so I'll leave this as an idea for you.

Also not sure why the test failed:

RuntimeError: [enforce fail at alloc_cpu.cpp:83] err == 0. DefaultCPUAllocator: can't allocate memory: you tried to allocate 9999800000 bytes. Error code 12 (Cannot allocate memory)

That's surely unrelated to this PR.

@ezyang
Copy link
Contributor

ezyang commented Dec 2, 2022

@pytorchbot rebase

@ezyang
Copy link
Contributor

ezyang commented Dec 2, 2022

I think when we fixed it in non VSX, we relied on UBSAN to tell us about it. But I guess we don't have UBSAN setup on this platform, so meh

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

This results in e.g. failures in TestNNDeviceTypeCPU.test_groupnorm_nhwc_cpu_float32

Fixes pytorch#32502
@pytorchmergebot
Copy link
Collaborator

Successfully rebased vsx-loadu onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout vsx-loadu && git pull --rebase)

@ezyang
Copy link
Contributor

ezyang commented Dec 2, 2022

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@Flamefire Flamefire deleted the vsx-loadu branch December 2, 2022 22:06
kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
This results in e.g. failures in TestNNDeviceTypeCPU.test_groupnorm_nhwc_cpu_float32

So simply initialize the stack array with zeroes as expected and done in other implementations

Fixes pytorch#32502

Pull Request resolved: pytorch#89833
Approved by: https://github.com/ezyang
Flamefire added a commit to Flamefire/pytorch that referenced this pull request Sep 18, 2023
…d values

Similar to pytorch#89833 those function may access uninitialized memory leading
to undefined behavior/results.
Initialize with zeros as done before.
pytorchmergebot pushed a commit that referenced this pull request Mar 23, 2024
…d values (#122399)

Similar to #89833 those function may access uninitialized memory leading
to undefined behavior/results.
Initialize with zeros as done before.

Pull Request resolved: #122399
Approved by: https://github.com/ezyang
pytorch-bot bot pushed a commit that referenced this pull request Apr 22, 2024
…d values (#122399)

Similar to #89833 those function may access uninitialized memory leading
to undefined behavior/results.
Initialize with zeros as done before.

Pull Request resolved: #122399
Approved by: https://github.com/ezyang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged module: cpu CPU specific problem (e.g., perf, algorithm) open source topic: bug fixes topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky test test_cos_scalar_cpu TestAutogradDeviceTypeCPU on MacOS
5 participants