Skip to content

Initialize view_replay_enabled_ in the AutogradState ctor#100822

Closed
vors wants to merge 1 commit intopytorch:mainfrom
vors:sergei/view_replay_enabled
Closed

Initialize view_replay_enabled_ in the AutogradState ctor#100822
vors wants to merge 1 commit intopytorch:mainfrom
vors:sergei/view_replay_enabled

Conversation

@vors
Copy link
Copy Markdown
Contributor

@vors vors commented May 7, 2023

Cruise uses clang static analyzer internally.
In the v2.0.0 release of PyTorch it found this problem

In file included from external/pytorch/aten/src/ATen/ATen.h:7:
In file included from external/pytorch/aten/src/ATen/Context.h:3:
In file included from external/pytorch/aten/src/ATen/CPUGeneratorImpl.h:3:
In file included from external/pytorch/aten/src/ATen/core/Generator.h:22:
In file included from external/pytorch/c10/core/GeneratorImpl.h:8:
In file included from external/pytorch/c10/core/TensorImpl.h:6:
external/pytorch/c10/core/InferenceMode.h:58:5: warning: Passed-by-value struct argument contains uninitialized data (e.g., field: 'view_replay_enabled_')
    AutogradState::set_tls_state(AutogradState(
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

In other words, the value of view_replay_enabled_ could be initialized which may lead to subtle bugs later on.

This PR addresses the warning by explicitly initializing it to false.

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 7, 2023

🔗 Helpful Links

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

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

✅ No Failures

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

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

@Skylion007 Skylion007 added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels May 8, 2023
@Skylion007
Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot
Copy link
Copy Markdown
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

chuanqi129 pushed a commit to chuanqi129/pytorch that referenced this pull request Dec 18, 2023
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 25, 2026
…0822)

Cruise uses [clang static analyzer](https://clang-analyzer.llvm.org/) internally.
In the v2.0.0 release of PyTorch it found this problem

```
In file included from external/pytorch/aten/src/ATen/ATen.h:7:
In file included from external/pytorch/aten/src/ATen/Context.h:3:
In file included from external/pytorch/aten/src/ATen/CPUGeneratorImpl.h:3:
In file included from external/pytorch/aten/src/ATen/core/Generator.h:22:
In file included from external/pytorch/c10/core/GeneratorImpl.h:8:
In file included from external/pytorch/c10/core/TensorImpl.h:6:
external/pytorch/c10/core/InferenceMode.h:58:5: warning: Passed-by-value struct argument contains uninitialized data (e.g., field: 'view_replay_enabled_')
    AutogradState::set_tls_state(AutogradState(
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```

In other words, the value of `view_replay_enabled_` could be initialized which may lead to subtle bugs later on.

This PR addresses the warning by explicitly initializing it to `false`.

Pull Request resolved: pytorch#100822
Approved by: https://github.com/Skylion007
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 open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants