From d0539dcc3693458f89e75a4f4d0d6534c40ebfa3 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sun, 11 Nov 2018 22:50:42 -0800 Subject: [PATCH 1/4] Prevent dead-stripping by explicitly calling init --- src/core/lib/surface/init.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index c6198b8ae76..6d58c78ffc4 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -114,8 +114,21 @@ void grpc_register_plugin(void (*init)(void), void (*destroy)(void)) { g_number_of_plugins++; } +// For debug of the timer manager crash only. +// TODO (mxyan): remove after bug is fixed. +#ifdef GRPC_DEBUG_TIMER_MANAGER +void init_debug_timer_manager(); +#endif + void grpc_init(void) { int i; + +// For debug of the timer manager crash only. +// TODO (mxyan): remove after bug is fixed. + #ifdef GRPC_DEBUG_TIMER_MANAGER + init_debug_timer_manager(); + #endif + gpr_once_init(&g_basic_init, do_basic_init); gpr_mu_lock(&g_init_mu); From 04cef1fd19fd77c5b758057fc844dca4c5c858a2 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Nov 2018 09:50:21 -0800 Subject: [PATCH 2/4] Revert "Prevent dead-stripping by explicitly calling init" This reverts commit d0539dcc3693458f89e75a4f4d0d6534c40ebfa3. --- src/core/lib/surface/init.cc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 6d58c78ffc4..c6198b8ae76 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -114,21 +114,8 @@ void grpc_register_plugin(void (*init)(void), void (*destroy)(void)) { g_number_of_plugins++; } -// For debug of the timer manager crash only. -// TODO (mxyan): remove after bug is fixed. -#ifdef GRPC_DEBUG_TIMER_MANAGER -void init_debug_timer_manager(); -#endif - void grpc_init(void) { int i; - -// For debug of the timer manager crash only. -// TODO (mxyan): remove after bug is fixed. - #ifdef GRPC_DEBUG_TIMER_MANAGER - init_debug_timer_manager(); - #endif - gpr_once_init(&g_basic_init, do_basic_init); gpr_mu_lock(&g_init_mu); From b8c9648f60a99cc8bd94f02c71bda240efba728a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Nov 2018 10:00:28 -0800 Subject: [PATCH 3/4] Directly calling logging function to prevent dead-stripping --- src/core/lib/gpr/sync_posix.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/core/lib/gpr/sync_posix.cc b/src/core/lib/gpr/sync_posix.cc index 69bd6094850..dba58c72e79 100644 --- a/src/core/lib/gpr/sync_posix.cc +++ b/src/core/lib/gpr/sync_posix.cc @@ -30,11 +30,11 @@ // For debug of the timer manager crash only. // TODO (mxyan): remove after bug is fixed. #ifdef GRPC_DEBUG_TIMER_MANAGER -void (*g_grpc_debug_timer_manager_stats)( +void GRPCDebugTimerManagerLogStats( int64_t timer_manager_init_count, int64_t timer_manager_shutdown_count, int64_t fork_count, int64_t timer_wait_err, int64_t timer_cv_value, int64_t timer_mu_value, int64_t abstime_sec_value, - int64_t abstime_nsec_value) = nullptr; + int64_t abstime_nsec_value); int64_t g_timer_manager_init_count = 0; int64_t g_timer_manager_shutdown_count = 0; int64_t g_fork_count = 0; @@ -119,15 +119,13 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) { // For debug of the timer manager crash only. // TODO (mxyan): remove after bug is fixed. if (GPR_UNLIKELY(!(err == 0 || err == ETIMEDOUT || err == EAGAIN))) { - if (g_grpc_debug_timer_manager_stats) { - g_timer_wait_err = err; - g_timer_cv_value = (int64_t)cv; - g_timer_mu_value = (int64_t)mu; - g_grpc_debug_timer_manager_stats( - g_timer_manager_init_count, g_timer_manager_shutdown_count, - g_fork_count, g_timer_wait_err, g_timer_cv_value, g_timer_mu_value, - g_abstime_sec_value, g_abstime_nsec_value); - } + g_timer_wait_err = err; + g_timer_cv_value = (int64_t)cv; + g_timer_mu_value = (int64_t)mu; + GRPCDebugTimerManagerLogStats( + g_timer_manager_init_count, g_timer_manager_shutdown_count, + g_fork_count, g_timer_wait_err, g_timer_cv_value, g_timer_mu_value, + g_abstime_sec_value, g_abstime_nsec_value); } #endif GPR_ASSERT(err == 0 || err == ETIMEDOUT || err == EAGAIN); From 0960acd05a020ceeea9ab99c3bf4d3217e25750e Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Nov 2018 10:16:07 -0800 Subject: [PATCH 4/4] clang-format --- src/core/lib/gpr/sync_posix.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/lib/gpr/sync_posix.cc b/src/core/lib/gpr/sync_posix.cc index dba58c72e79..dc6392a819c 100644 --- a/src/core/lib/gpr/sync_posix.cc +++ b/src/core/lib/gpr/sync_posix.cc @@ -30,11 +30,13 @@ // For debug of the timer manager crash only. // TODO (mxyan): remove after bug is fixed. #ifdef GRPC_DEBUG_TIMER_MANAGER -void GRPCDebugTimerManagerLogStats( - int64_t timer_manager_init_count, int64_t timer_manager_shutdown_count, - int64_t fork_count, int64_t timer_wait_err, int64_t timer_cv_value, - int64_t timer_mu_value, int64_t abstime_sec_value, - int64_t abstime_nsec_value); +void GRPCDebugTimerManagerLogStats(int64_t timer_manager_init_count, + int64_t timer_manager_shutdown_count, + int64_t fork_count, int64_t timer_wait_err, + int64_t timer_cv_value, + int64_t timer_mu_value, + int64_t abstime_sec_value, + int64_t abstime_nsec_value); int64_t g_timer_manager_init_count = 0; int64_t g_timer_manager_shutdown_count = 0; int64_t g_fork_count = 0;