[stacktrace] Getting a stacktrace from unhandled exception in windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[stacktrace] Getting a stacktrace from unhandled exception in windows

Boost - Users mailing list
I am trying use boost stacktrace to get a stack dump when my program encounters an unhandled exception under windows. I have installed a signal handler as described in the stacktrace documentation, and it gets called. However, the resulting stack trace is after everything has been unwound.

For example, when I force a failure by dereferenceing a null pointer many levels down in my function hierarchy, the stack trace shows:

  0# boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl<char const *> at f:\home\tools\boost\boost\stacktrace\safe_dump_to.hpp:68
  1# boost::stacktrace::safe_dump_to at f:\home\tools\boost\boost\stacktrace\safe_dump_to.hpp:120
  2# my_signal_handler at f:\home\test\main.cpp:233
  3# 0x5171407B
  4# my_signal_handler at f:\home\test\main.cpp:235
  5# 0x51713883
  6# __tmainCRTStartup at f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:603
  7# WinMainCRTStartup at f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:403
  8# BaseThreadInitThunk in kernel32
  9# RtlInitializeExceptionChain in ntdll
10# RtlInitializeExceptionChain in ntdll

This is not particularly helpful, of course -- I want to know the call stack at the point of the failure. Is there any way to get that? What am I missing?

Thanks,

Don

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [stacktrace] Getting a stacktrace from unhandled exception in windows

Boost - Users mailing list

Unless you need the stacktrace to be logged to a text file, I suggest you look at this system-provided facility: https://msdn.microsoft.com/en-us/library/windows/desktop/bb787181(v=vs.85).aspx



msdn.microsoft.com
Starting with Windows Server 2008 and Windows Vista with Service Pack 1 (SP1), Windows Error Reporting (WER) can be configured so that full user-mode dumps are ...

The kernel will generate a dump that you can open in Visual Studio, windbg (free) and probably in other tools too. It's basically the equivalent of unix core-dumps. You can also configure the level of detail in the dump, so the resulting file can be small in case you want to collect them from end-users. Do note that the dump files are usable only with the exact build which generated them, i.e., archive all builds (and their PDBs) that you've ever distributed to somebody.


IOW, you can get out more information than with boost.stacktrace with zero coding.


From: Boost-users <[hidden email]> on behalf of Don via Boost-users <[hidden email]>
Sent: Monday, September 11, 2017 1:27:47 AM
To: [hidden email]
Cc: Don
Subject: [Boost-users] [stacktrace] Getting a stacktrace from unhandled exception in windows
 
I am trying use boost stacktrace to get a stack dump when my program encounters an unhandled exception under windows. I have installed a signal handler as described in the stacktrace documentation, and it gets called. However, the resulting stack trace is after everything has been unwound.

For example, when I force a failure by dereferenceing a null pointer many levels down in my function hierarchy, the stack trace shows:

  0# boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl<char const *> at f:\home\tools\boost\boost\stacktrace\safe_dump_to.hpp:68
  1# boost::stacktrace::safe_dump_to at f:\home\tools\boost\boost\stacktrace\safe_dump_to.hpp:120
  2# my_signal_handler at f:\home\test\main.cpp:233
  3# 0x5171407B
  4# my_signal_handler at f:\home\test\main.cpp:235
  5# 0x51713883
  6# __tmainCRTStartup at f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:603
  7# WinMainCRTStartup at f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:403
  8# BaseThreadInitThunk in kernel32
  9# RtlInitializeExceptionChain in ntdll
10# RtlInitializeExceptionChain in ntdll

This is not particularly helpful, of course -- I want to know the call stack at the point of the failure. Is there any way to get that? What am I missing?

Thanks,

Don

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [stacktrace] Getting a stacktrace from unhandled exception in windows

Boost - Users mailing list
In reply to this post by Boost - Users mailing list

Also forgot to say: a minidump will contain stack traces of all threads, not just the calling thread. IME, if the program is multithreaded, it's immensely helpful to know what other threads were doing when one particular thread crashed.


From: Boost-users <[hidden email]> on behalf of Don via Boost-users <[hidden email]>
Sent: Monday, September 11, 2017 1:27:47 AM
To: [hidden email]
Cc: Don
Subject: [Boost-users] [stacktrace] Getting a stacktrace from unhandled exception in windows
 
I am trying use boost stacktrace to get a stack dump when my program encounters an unhandled exception under windows. I have installed a signal handler as described in the stacktrace documentation, and it gets called. However, the resulting stack trace is after everything has been unwound.

For example, when I force a failure by dereferenceing a null pointer many levels down in my function hierarchy, the stack trace shows:

  0# boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl<char const *> at f:\home\tools\boost\boost\stacktrace\safe_dump_to.hpp:68
  1# boost::stacktrace::safe_dump_to at f:\home\tools\boost\boost\stacktrace\safe_dump_to.hpp:120
  2# my_signal_handler at f:\home\test\main.cpp:233
  3# 0x5171407B
  4# my_signal_handler at f:\home\test\main.cpp:235
  5# 0x51713883
  6# __tmainCRTStartup at f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:603
  7# WinMainCRTStartup at f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:403
  8# BaseThreadInitThunk in kernel32
  9# RtlInitializeExceptionChain in ntdll
10# RtlInitializeExceptionChain in ntdll

This is not particularly helpful, of course -- I want to know the call stack at the point of the failure. Is there any way to get that? What am I missing?

Thanks,

Don

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [stacktrace] Getting a stacktrace from unhandled exception in windows

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
-------- Original Message --------
Subject: Boost-users Digest, Vol 4770, Issue 1
From: [hidden email]
To: [hidden email]
Date: 9/10/2017 10:56 PM

> Subject: Re: [Boost-users] [stacktrace] Getting a stacktrace from unhandled exception in windows
> From: Stian Zeljko Vrba <[hidden email]>
> Date: 9/10/2017 10:54 PM
>
> Unless you need the stacktrace to be logged to a text file, I suggest you look at this system-provided
>facility: https://msdn.microsoft.com/en-us/library/windows/desktop/bb787181(v=vs.85).aspx 
><https://msdn.microsoft.com/en-us/library/windows/desktop/bb787181%28v=vs.85%29.aspx>
>
> ...> IOW, you can get out more information than with boost.stacktrace with zero coding.
>
>> *Sent:* Monday, September 11, 2017 1:27:47 AM
>> *To:* [hidden email]
>> *Subject:* [Boost-users] [stacktrace] Getting a stacktrace from unhandled exception in windows
>>>> I am trying use boost stacktrace to get a stack dump when my program encounters an unhandled exception
>> under windows. I have installed a signal handler as described in the stacktrace documentation, and it
>> gets called. However, the resulting stack trace is after everything has been unwound.
>>
>> For example, when I force a failure by dereferenceing a null pointer many levels down in my function
>> hierarchy, the stack trace shows:
>>
>>    0# boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl<char const *> at f:\home\tools\boost\boost\stacktrace\safe_dump_to.hpp:68
>>    1# boost::stacktrace::safe_dump_to at f:\home\tools\boost\boost\stacktrace\safe_dump_to.hpp:120
>>    2# my_signal_handler at f:\home\test\main.cpp:233
>>    3# 0x5171407B
>>    4# my_signal_handler at f:\home\test\main.cpp:235
>>    5# 0x51713883
>>    6# __tmainCRTStartup at f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:603
>>    7# WinMainCRTStartup at f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:403
>>    8# BaseThreadInitThunk in kernel32
>>    9# RtlInitializeExceptionChain in ntdll
>> 10# RtlInitializeExceptionChain in ntdll
>>
>> This is not particularly helpful, of course -- I want to know the call stack at the point of the
>> failure. Is there any way to get that? What am I missing?
 
Thanks for the suggestion, but yes, I want to log the data to a log file. It seems from the stacktrace documentation that this should work.
 
Don

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users