Skip to content

Commit

Permalink
Print GC status on segfault to ease debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jun 24, 2015
1 parent bb7d272 commit 8edd9e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,12 +851,8 @@ gc_debug_check_other()
return gc_debug_alloc_check(&gc_debug_env.other);
}

static inline void
gc_debug_print()
void gc_debug_print_status()
{
gc_debug_init();
if (!gc_debug_alloc_check(&gc_debug_env.print))
return;
uint64_t pool_count = gc_debug_env.pool.num;
uint64_t other_count = gc_debug_env.other.num;
jl_printf(JL_STDOUT,
Expand All @@ -865,6 +861,15 @@ gc_debug_print()
n_pause);
}

static inline void
gc_debug_print()
{
gc_debug_init();
if (!gc_debug_alloc_check(&gc_debug_env.print))
return;
gc_debug_print_status();
}

#else

static inline int
Expand Down
2 changes: 2 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ void __cdecl crt_sig_handler(int sig, int num)
ios_printf(ios_stderr,"\nsignal (%d): %s\n", sig, strsignal(sig));
bt_size = rec_backtrace(bt_data, MAX_BT_SIZE);
jlbacktrace();
gc_debug_print_status();
raise(sig);
}
}
Expand Down Expand Up @@ -264,6 +265,7 @@ void sigdie_handler(int sig, siginfo_t *info, void *context)
bt_size = rec_backtrace_ctx(bt_data, MAX_BT_SIZE, (ucontext_t*)context);
#endif
jlbacktrace();
gc_debug_print_status();
if (sig != SIGSEGV &&
sig != SIGBUS &&
sig != SIGILL &&
Expand Down
5 changes: 5 additions & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ STATIC_INLINE jl_value_t *newstruct(jl_datatype_t *type)
// empty structs are a GNU extension
#define sizeof_jl_taggedvalue_t (sizeof(void*))

#ifdef GC_DEBUG_ENV
void gc_debug_print_status();
#else
#define gc_debug_print_status()
#endif
int jl_assign_type_uid(void);
jl_value_t *jl_cache_type_(jl_datatype_t *type);
int jl_get_t_uid_ctr(void);
Expand Down

0 comments on commit 8edd9e4

Please sign in to comment.