Fix prof_backtrace() reentrancy level

This commit is contained in:
Yinan Zhang 2019-09-03 17:11:06 -07:00
parent 785b84e603
commit 671f120e26

View File

@ -208,8 +208,8 @@ bt_init(prof_bt_t *bt, void **vec) {
} }
#ifdef JEMALLOC_PROF_LIBUNWIND #ifdef JEMALLOC_PROF_LIBUNWIND
void static void
prof_backtrace(prof_bt_t *bt) { prof_backtrace_impl(prof_bt_t *bt) {
int nframes; int nframes;
cassert(config_prof); cassert(config_prof);
@ -250,8 +250,8 @@ prof_unwind_callback(struct _Unwind_Context *context, void *arg) {
return _URC_NO_REASON; return _URC_NO_REASON;
} }
void static void
prof_backtrace(prof_bt_t *bt) { prof_backtrace_impl(prof_bt_t *bt) {
prof_unwind_data_t data = {bt, PROF_BT_MAX}; prof_unwind_data_t data = {bt, PROF_BT_MAX};
cassert(config_prof); cassert(config_prof);
@ -259,8 +259,8 @@ prof_backtrace(prof_bt_t *bt) {
_Unwind_Backtrace(prof_unwind_callback, &data); _Unwind_Backtrace(prof_unwind_callback, &data);
} }
#elif (defined(JEMALLOC_PROF_GCC)) #elif (defined(JEMALLOC_PROF_GCC))
void static void
prof_backtrace(prof_bt_t *bt) { prof_backtrace_impl(prof_bt_t *bt) {
#define BT_FRAME(i) \ #define BT_FRAME(i) \
if ((i) < PROF_BT_MAX) { \ if ((i) < PROF_BT_MAX) { \
void *p; \ void *p; \
@ -422,13 +422,22 @@ prof_backtrace(prof_bt_t *bt) {
#undef BT_FRAME #undef BT_FRAME
} }
#else #else
void static void
prof_backtrace(prof_bt_t *bt) { prof_backtrace_impl(prof_bt_t *bt) {
cassert(config_prof); cassert(config_prof);
not_reached(); not_reached();
} }
#endif #endif
void
prof_backtrace(prof_bt_t *bt) {
cassert(config_prof);
tsd_t *tsd = tsd_fetch();
pre_reentrancy(tsd, NULL);
prof_backtrace_impl(bt);
post_reentrancy(tsd);
}
malloc_mutex_t * malloc_mutex_t *
prof_gctx_mutex_choose(void) { prof_gctx_mutex_choose(void) {
unsigned ngctxs = atomic_fetch_add_u(&cum_gctxs, 1, ATOMIC_RELAXED); unsigned ngctxs = atomic_fetch_add_u(&cum_gctxs, 1, ATOMIC_RELAXED);