Skip to content

Commit fb847d4

Browse files
Use RtlCaptureStackBackTrace instead of StackWolker64 in case of missing context
1 parent 51f0700 commit fb847d4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

backward.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,15 @@ class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder {
11361136
void *error_addr = nullptr) {
11371137
set_context(static_cast<CONTEXT*>(context));
11381138
set_error_addr(error_addr);
1139+
1140+
if (!context) {
1141+
_stacktrace.resize(depth);
1142+
const WORD capturedFrames = RtlCaptureStackBackTrace(
1143+
0, static_cast<DWORD>(depth), _stacktrace.data(), NULL);
1144+
_stacktrace.resize(capturedFrames);
1145+
return capturedFrames;
1146+
}
1147+
11391148
CONTEXT localCtx; // used when no context is provided
11401149

11411150
if (depth == 0) {

0 commit comments

Comments
 (0)