Skip to content

Commit 0144414

Browse files
committed
win32_checkTLS: add a panic message and break into the debugger
if there is one. Previously this would exit silently and mysteriously, and unlike POSIX-likes abort() doesn't generally break into the debugger on Win32.
1 parent 43dfd9c commit 0144414

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

win32/perllib.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ xs_init(pTHX)
4848

4949
#include "perlhost.h"
5050

51+
#define PANIC_THREAD_ID_MSG "panic: thread id mismatch\n"
52+
53+
#define panic_thread_id() \
54+
(void)WriteFile(GetStdHandle(STD_ERROR_HANDLE), \
55+
PANIC_THREAD_ID_MSG, sizeof(PANIC_THREAD_ID_MSG)-1, \
56+
NULL, NULL)
57+
5158
void
5259
win32_checkTLS(PerlInterpreter *host_perl)
5360
{
@@ -63,13 +70,17 @@ win32_checkTLS(PerlInterpreter *host_perl)
6370
if(tid != host_perl->Isys_intern.cur_tid) {
6471
dTHX; /* heavyweight */
6572
if (host_perl != my_perl) {
73+
panic_thread_id();
74+
DebugBreak();
6675
abort();
6776
}
6877
host_perl->Isys_intern.cur_tid = tid;
6978
}
7079
#else
7180
dTHX;
7281
if (host_perl != my_perl) {
82+
panic_thread_id();
83+
DebugBreak();
7384
abort();
7485
}
7586
#endif

0 commit comments

Comments
 (0)