pytorch - ✅(Solved) Fix Support TORCH_SHOW_CPP_STACKTRACES=1 on Windows [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#177322Fetched 2026-04-08 00:42:10
View on GitHub
Comments
2
Participants
3
Timeline
37
Reactions
0
Author
Timeline (top)
mentioned ×14subscribed ×14labeled ×5commented ×2

Error Message

It would be nice to have this feature because it is extremely helpful for remote debugging. I discovered this when trying to debug a windows CI error here: https://github.com/pytorch/pytorch/pull/168912#issuecomment-4036577173 A more complete description of the underlying issue (a too-old driver) is here: https://github.com/pytorch/vision/issues/9437

Root Cause

It would be nice to have this feature because it is extremely helpful for remote debugging. I discovered this when trying to debug a windows CI error here: https://github.com/pytorch/pytorch/pull/168912#issuecomment-4036577173 A more complete description of the underlying issue (a too-old driver) is here: https://github.com/pytorch/vision/issues/9437

Fix Action

Fixed

PR fix notes

PR #177468: fix:support unwind for windows(#177322)

Description (problem / solution / changelog)

Fixes #177322

This PR supports the unwind function on Windows systems.

  1. It implements three functions: unwind, libraryFor, and symbolize.
  2. It uses relevant Windows APIs to implement these functions.

Changed files

  • test/profiler/test_profiler_unwind.py (added, +125/-0)
  • torch/csrc/profiler/unwind/unwind.cpp (modified, +118/-1)
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

Right now, TORCH_SHOW_CPP_STACKTRACES=1 does not work properly for windows. This is indeed documented with a warning in the code: https://github.com/pytorch/pytorch/blob/d2d12ef34f45ca329ac3781b9521cc80a368328f/torch/csrc/profiler/unwind/unwind.cpp#L6-L13

It would be nice to have this feature because it is extremely helpful for remote debugging. I discovered this when trying to debug a windows CI error here: https://github.com/pytorch/pytorch/pull/168912#issuecomment-4036577173 A more complete description of the underlying issue (a too-old driver) is here: https://github.com/pytorch/vision/issues/9437

codex suggests that c10::get_lazy_backtrace could be reused to get a C++ stacktrace in windows, but I haven't bothered to try it out at this point, partially because I hardly touch windows: https://chatgpt.com/s/cd_69b33334ed988191a70dd98ab65d623f

Alternatives

No response

Additional context

This is a nice to have rather than a must have.

cc @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex @ZainRizvi @huydhn

extent analysis

Fix Plan

To enable TORCH_SHOW_CPP_STACKTRACES=1 on Windows, we can reuse c10::get_lazy_backtrace to get a C++ stacktrace.

Steps to Fix

  • Modify unwind.cpp to use c10::get_lazy_backtrace on Windows:
#ifdef _WIN32
  // Use c10::get_lazy_backtrace on Windows
  auto backtrace = c10::get_lazy_backtrace();
  // Print the backtrace
  for (const auto& frame : backtrace) {
    std::cout << frame << std::endl;
  }
#else
  // Existing implementation for non-Windows platforms
#endif
  • Update the warning in the code to reflect the new implementation.

Verification

  • Set TORCH_SHOW_CPP_STACKTRACES=1 and run a test on Windows.
  • Verify that the C++ stacktrace is printed correctly.

Example Use Case

// Enable TORCH_SHOW_CPP_STACKTRACES
setenv("TORCH_SHOW_CPP_STACKTRACES", "1", 1);

// Trigger an error to test the stacktrace
throw std::runtime_error("Test error");

This should print the C++ stacktrace when the error is thrown.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING