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 Jul 10, 2015
1 parent c8b5678 commit 9ee4804
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,8 @@ static inline int 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 @@ -860,6 +857,14 @@ static inline void 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 gc_debug_check_other()
Expand Down
2 changes: 2 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,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 @@ -269,6 +270,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 9ee4804

Please sign in to comment.