From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 0092B46970E for ; Thu, 9 Jan 2020 23:15:35 +0300 (MSK) Received: by mail-lf1-f65.google.com with SMTP id y1so6161069lfb.6 for ; Thu, 09 Jan 2020 12:15:35 -0800 (PST) Date: Thu, 9 Jan 2020 23:15:33 +0300 From: Cyrill Gorcunov Message-ID: <20200109201533.GF2436@uranus> References: <20200109200636.26308-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200109200636.26308-1-skaplun@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] refactoring: drop excess 16Kb bss buffer List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy On Thu, Jan 09, 2020 at 11:06:36PM +0300, Sergey Kaplun wrote: > We already have 12Kb thread-safe static buffer > in `lib/small/small/static.h`, that can be used instead of 16Kb > bss buffer in `src/lib/core/backtrace.cc` for backtrace payload. > > Closes #4650 > --- > > branch: https://github.com/tarantool/tarantool/tree/skaplun/drop-bss-buff > issue: https://github.com/tarantool/tarantool/issues/4650 > > src/lib/core/backtrace.cc | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/src/lib/core/backtrace.cc b/src/lib/core/backtrace.cc > index 77f77b05c..eabd986df 100644 > --- a/src/lib/core/backtrace.cc > +++ b/src/lib/core/backtrace.cc > @@ -47,6 +47,7 @@ > #include > > #include "small/region.h" > +#include "small/static.h" > /* > * We use a global static buffer because it is too late to do any > * allocation when we are printing backtrace and fiber stack is > @@ -55,8 +56,6 @@ > > #define BACKTRACE_NAME_MAX 200 > > -static char backtrace_buf[4096 * 4]; > - > static __thread struct region cache_region; > static __thread struct mh_i64ptr_t *proc_cache = NULL; > > @@ -140,8 +139,9 @@ backtrace() > unw_getcontext(&unw_context); > unw_cursor_t unw_cur; > unw_init_local(&unw_cur, &unw_context); > + char *backtrace_buf = (char *)static_alloc(SMALL_STATIC_SIZE); > char *p = backtrace_buf; > - char *end = p + sizeof(backtrace_buf) - 1; > + char *end = p + SMALL_STATIC_SIZE - 1; > int unw_status; > *p = '\0'; > while ((unw_status = unw_step(&unw_cur)) > 0) { static_alloc has all rights to return NULL, thus you better add a test at least. NAK for a while