Skip to content

Conversation

@Aidyn-A
Copy link
Collaborator

@Aidyn-A Aidyn-A commented Aug 24, 2024

Fixes #119905

The TORCH_SHOW_CPP_STACKTRACES=1 setting on ARM causes infinite recursive unwind because on failure a StackTraceFetcher attempts to unwind the failed instruction:

r->cpp_frames_ = unwind::unwind();

then the unwind itself fails:
TORCH_CHECK(
false,
"record_context_cpp is not support on non-linux non-x86_64 platforms");

and it causes another attempt to unwind the failure in unwind()...

In summary, the executed instruction is equivalent to:

std::vector<void*> unwind() {
  // some instructions ...
  return unwind();
}

This PR replaces TORCH_CHECK by TORCH_WARN_ONCE as it will not cause an uncontrolled recursion. The only side effect would be an empty back-trace.

Huge thanks to @nWEIdia who found the root cause!

cc @malfet @snadampal @milpuz01

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 24, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 1de64b9 with merge base 2553278 (image):
💚 Looks good so far! There are no failures yet. 💚

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

Copy link
Collaborator

@nWEIdia nWEIdia left a comment

Choose a reason for hiding this comment

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

Geniously speed of light forward fix!

@Aidyn-A Aidyn-A added ciflow/trunk Trigger trunk jobs on your pull request module: arm Related to ARM architectures builds of PyTorch. Includes Apple M1 labels Aug 24, 2024
@malfet
Copy link
Contributor

malfet commented Aug 24, 2024

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@nWEIdia
Copy link
Collaborator

nWEIdia commented Aug 24, 2024

Perhaps as a follow up, we can remove IS_MACOS and the inductor check line?

@Aidyn-A Aidyn-A requested a review from a team as a code owner August 26, 2024 16:32
@albanD albanD removed their request for review August 26, 2024 16:55
@Aidyn-A
Copy link
Collaborator Author

Aidyn-A commented Aug 26, 2024

All tests are green.

@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

Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
Fixes pytorch#119905

The `TORCH_SHOW_CPP_STACKTRACES=1` setting on ARM causes infinite recursive unwind because on failure a `StackTraceFetcher` attempts to unwind the <ins>failed instruction</ins>: https://github.com/pytorch/pytorch/blob/5ad759ca33ba8299cf7e1a6bb1dff7c9a5555e29/torch/csrc/profiler/combined_traceback.cpp#L25
then the unwind itself fails:
https://github.com/pytorch/pytorch/blob/5ad759ca33ba8299cf7e1a6bb1dff7c9a5555e29/torch/csrc/profiler/unwind/unwind.cpp#L10-L12
and it causes another attempt to unwind the failure in `unwind()`...

In summary, the executed instruction is equivalent to:
```C++
std::vector<void*> unwind() {
  // some instructions ...
  return unwind();
}
```
This PR replaces `TORCH_CHECK` by `TORCH_WARN_ONCE` as it will not cause an uncontrolled recursion. The only side effect would be an empty back-trace.

Huge thanks to @nWEIdia who found the root cause!

Pull Request resolved: pytorch#134387
Approved by: https://github.com/eqy, https://github.com/nWEIdia, https://github.com/malfet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: arm Related to ARM architectures builds of PyTorch. Includes Apple M1 open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inductor test segfault on macos (and arm64) when C++ stacktraces are enabled

6 participants