Skip to content

Add libbacktrace in Linux Debug build#26257

Closed
tianleiwu wants to merge 3 commits into
mainfrom
tlwu/libbacktrace
Closed

Add libbacktrace in Linux Debug build#26257
tianleiwu wants to merge 3 commits into
mainfrom
tlwu/libbacktrace

Conversation

@tianleiwu
Copy link
Copy Markdown
Contributor

@tianleiwu tianleiwu commented Oct 7, 2025

Show filename and line number in stack trace in Linux debug build.

I only tested CUDA build. Might need extra work (link libbacktrace) for CPU debug builds.

@tianleiwu tianleiwu marked this pull request as draft October 7, 2025 21:20
@snnn
Copy link
Copy Markdown
Contributor

snnn commented Oct 8, 2025

abseil has this functionality. Or we may enable C++20 which has other benefits as well.

@tianleiwu
Copy link
Copy Markdown
Contributor Author

abseil has this functionality. Or we may enable C++20 which has other benefits as well.

You are right. Abseil uses libunwind and libbacktrace internally, so use abseil backtrace is a better solution.

@tianleiwu tianleiwu closed this Oct 8, 2025
tianleiwu added a commit that referenced this pull request May 7, 2026
Replace glibc backtrace()/backtrace_symbols() with abseil's
GetStackTrace()/Symbolize() in debug builds on Linux/POSIX.

The previous implementation produced raw addresses requiring manual
addr2line translation. The new implementation produces demangled
function names (e.g. onnxruntime::InferenceSession::Run) directly
in exception messages.

No new dependency is introduced — absl::stacktrace and absl::symbolize
are already linked via ABSEIL_LIBS. Windows stack traces (C++23
<stacktrace>) are unchanged.

Closes #26257
tianleiwu added a commit that referenced this pull request May 7, 2026
Replace glibc backtrace()/backtrace_symbols() with abseil's
GetStackTrace()/Symbolize() in debug builds on Linux/POSIX.

The previous implementation produced raw addresses requiring manual
addr2line translation. The new implementation produces demangled
function names (e.g. onnxruntime::InferenceSession::Run) directly
in exception messages.

No new dependency is introduced — absl::stacktrace and absl::symbolize
are already linked via ABSEIL_LIBS. Windows stack traces (C++23
<stacktrace>) are unchanged.

Closes #26257
tianleiwu added a commit that referenced this pull request May 8, 2026
Replace glibc backtrace()/backtrace_symbols() with abseil's
GetStackTrace()/Symbolize() in debug builds on Linux/POSIX.

The previous implementation produced raw addresses requiring manual
addr2line translation. The new implementation produces demangled
function names (e.g. onnxruntime::InferenceSession::Run) directly
in exception messages.

No new dependency is introduced — absl::stacktrace and absl::symbolize
are already linked via ABSEIL_LIBS. Windows stack traces (C++23
<stacktrace>) are unchanged.

Closes #26257
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.

2 participants