back-ported dbghlp fix (#946)

back-ported dbghlp fix
This commit is contained in:
Arvid Norberg 2016-07-26 01:05:32 -04:00 committed by GitHub
parent 0ea449a7b5
commit 6777ec5d05
2 changed files with 14 additions and 0 deletions

View File

@ -146,12 +146,19 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
#include "windows.h"
#include "libtorrent/utf8.hpp"
#include "libtorrent/thread.hpp"
#include "winbase.h"
#include "dbghelp.h"
static libtorrent::mutex dbghlp_mutex;
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
{
// all calls to DbgHlp.dll are thread-unsafe. i.e. they all need to be
// synchronized and not called concurrently. This mutex serializes access
libtorrent::mutex::scoped_lock l(dbghlp_mutex);
typedef USHORT (WINAPI *RtlCaptureStackBackTrace_t)(
__in ULONG FramesToSkip,
__in ULONG FramesToCapture,

View File

@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <windows.h> // fot SetErrorMode
#include <io.h> // for _dup and _dup2
#include <process.h> // for _getpid
#include <crtdbg.h>
#define dup _dup
#define dup2 _dup2
@ -224,6 +225,12 @@ EXPORT int main(int argc, char const* argv[])
| SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
SetUnhandledExceptionFilter(&seh_exception_handler);
#ifdef _DEBUG
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
#endif
#endif
#ifdef O_NONBLOCK