Skip to content

Commit 23088cc

Browse files
committed
win32 debug
1 parent c41658d commit 23088cc

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/jl_uv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ static void jl_signal_async_cb(uv_async_t *hdl)
5454
// This should abort the current loop and the julia code it returns to
5555
// or the safepoint in the callers of `uv_run` should throw the exception.
5656
(void)hdl;
57+
jl_debug_win32_sigint();
5758
uv_stop(jl_io_loop);
5859
}
5960

6061
void jl_wake_libuv(void)
6162
{
63+
jl_debug_win32_sigint();
6264
uv_async_send(&signal_async);
6365
}
6466

src/julia_internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,12 @@ jl_value_t *jl_lookup_match(jl_value_t *a, jl_value_t *b, jl_svec_t **penv, jl_s
638638

639639
unsigned jl_special_vector_alignment(size_t nfields, jl_value_t *field_type);
640640

641+
#ifdef _OS_WINDOWS_
642+
#define jl_debug_win32_sigint() jl_safe_printf("%d:%s\n", GetCurrentProcessId(), __func__);
643+
#else
644+
#define jl_debug_win32_sigint()
645+
#endif
646+
641647
#ifdef __cplusplus
642648
}
643649
#endif

src/safepoint.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ void jl_safepoint_wait_gc(void)
173173

174174
void jl_safepoint_enable_sigint(void)
175175
{
176+
jl_debug_win32_sigint();
176177
jl_mutex_lock_nogc(&safepoint_lock);
177178
// Make sure both safepoints are enabled exactly once for SIGINT.
178179
switch (jl_signal_pending) {
@@ -194,6 +195,7 @@ void jl_safepoint_enable_sigint(void)
194195

195196
void jl_safepoint_defer_sigint(void)
196197
{
198+
jl_debug_win32_sigint();
197199
jl_mutex_lock_nogc(&safepoint_lock);
198200
// Make sure the GC safepoint is disabled for SIGINT.
199201
if (jl_signal_pending == 2) {
@@ -205,6 +207,7 @@ void jl_safepoint_defer_sigint(void)
205207

206208
int jl_safepoint_consume_sigint(void)
207209
{
210+
jl_debug_win32_sigint();
208211
int has_signal = 0;
209212
jl_mutex_lock_nogc(&safepoint_lock);
210213
// Make sure both safepoints are disabled for SIGINT.

src/signals-win.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static char *strsignal(int sig)
4343

4444
static void jl_try_throw_sigint(void)
4545
{
46+
jl_debug_win32_sigint();
4647
jl_tls_states_t *ptls = jl_get_ptls_states();
4748
jl_safepoint_enable_sigint();
4849
jl_wake_libuv();
@@ -78,6 +79,7 @@ void __cdecl crt_sig_handler(int sig, int num)
7879
break;
7980
case SIGINT:
8081
signal(SIGINT, (void (__cdecl *)(int))crt_sig_handler);
82+
jl_debug_win32_sigint();
8183
if (exit_on_sigint)
8284
jl_exit(130); // 128 + SIGINT
8385
jl_try_throw_sigint();
@@ -126,6 +128,7 @@ HANDLE hMainThread = INVALID_HANDLE_VALUE;
126128
// Try to throw the exception in the master thread.
127129
static void jl_try_deliver_sigint(void)
128130
{
131+
jl_debug_win32_sigint();
129132
jl_tls_states_t *ptls = jl_all_task_states[0].ptls;
130133
jl_safepoint_enable_sigint();
131134
jl_wake_libuv();
@@ -166,6 +169,7 @@ static void jl_try_deliver_sigint(void)
166169

167170
static BOOL WINAPI sigint_handler(DWORD wsig) //This needs winapi types to guarantee __stdcall
168171
{
172+
jl_debug_win32_sigint();
169173
int sig;
170174
//windows signals use different numbers from unix (raise)
171175
switch(wsig) {
@@ -193,6 +197,7 @@ static LONG WINAPI _exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo,
193197
return EXCEPTION_CONTINUE_EXECUTION;
194198
case EXCEPTION_ACCESS_VIOLATION:
195199
if (jl_addr_is_safepoint(ExceptionInfo->ExceptionRecord->ExceptionInformation[1])) {
200+
jl_debug_win32_sigint();
196201
#ifdef JULIA_ENABLE_THREADING
197202
jl_set_gc_and_wait();
198203
// Do not raise sigint on worker thread
@@ -260,7 +265,9 @@ static LONG WINAPI _exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo,
260265
jl_safe_printf("UNKNOWN"); break;
261266
}
262267
jl_safe_printf(" at 0x%Ix -- ", (size_t)ExceptionInfo->ExceptionRecord->ExceptionAddress);
263-
jl_gdblookup((uintptr_t)ExceptionInfo->ExceptionRecord->ExceptionAddress);
268+
jl_safe_printf(" safepoint_addr 0x%Ix -- ",
269+
(size_t)(uintptr_t)jl_safepoint_pages);
270+
/* jl_gdblookup((uintptr_t)ExceptionInfo->ExceptionRecord->ExceptionAddress); */
264271

265272
jl_critical_error(0, ExceptionInfo->ContextRecord, jl_bt_data, &jl_bt_size);
266273
static int recursion = 0;

0 commit comments

Comments
 (0)