Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Egor Elchinov via Tarantool-patches
	<tarantool-patches@dev.tarantool.org>
Cc: Egor Elchinov <elchinov.es@gmail.com>
Subject: Re: [Tarantool-patches] [PATCH v2 2/4] fiber: add option and PoC for Lua parent backtrace
Date: Mon, 12 Jul 2021 15:09:11 +0300	[thread overview]
Message-ID: <YOww5+cfZum2rVTM@grain> (raw)
In-Reply-To: <fdc0e2385d01eff0baf2239f1b40d54b4fbb52de.1625827535.git.elchinov.es@gmail.com>

On Fri, Jul 09, 2021 at 02:03:51PM +0300, Egor Elchinov via Tarantool-patches wrote:
> 
> diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
> index 924ff3c82..dd26e2f13 100644
> --- a/src/lib/core/fiber.c
> +++ b/src/lib/core/fiber.c
> @@ -220,6 +220,10 @@ fiber_mprotect(void *addr, size_t len, int prot)
>  static __thread bool fiber_top_enabled = false;
>  #endif /* ENABLE_FIBER_TOP */
>  
> +#if ENABLE_BACKTRACE
> +static __thread bool fiber_parent_bt_enabled = false;
> +#endif /* ENABLE_BACKTRACE */
> +

So this variable is declared as TLS in a manner of fiber_top
functionality. You know I somehow find this fishy because
it is unclear why it is done this way. I think we should
revisit this moment for @fiber_top_enabled enabled as well
but not in this series, so lets leave it as is.

Please revisit snprintf calls in the patch and strncpy
as well because they _do_not_ append terminating \0 symbol
if destination size is not enough. I think we should add
\0 explicitly all the time.

I mean

+static int
+fiber_parent_backtrace_cb(int frameno, void *frameret, const char *func,
+			  size_t offset, void *cb_ctx)
+{
	...
+	char buf[512];
+	int l = snprintf(buf, sizeof(buf), "#%-2d %p in ", frameno, frameret);
+	if (func)
+		snprintf(buf + l, sizeof(buf) - l, "%s+%zu", func, offset);
+	else
+		snprintf(buf + l, sizeof(buf) - l, "?");

we could add

	buf[sizeof(buf)-1] = '\0';

Actually 512 bytes for function name should be more than enough but
better be on a safe side.

Other than that the patch looks ok to me, great job, thanks!

  reply	other threads:[~2021-07-12 12:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 11:03 [Tarantool-patches] [PATCH v2 0/4] fiber: introduce creation backtrace Egor Elchinov via Tarantool-patches
2021-07-09 11:03 ` [Tarantool-patches] [PATCH v2 1/4] fiber: add PoC for fiber " Egor Elchinov via Tarantool-patches
2021-07-12 11:42   ` Cyrill Gorcunov via Tarantool-patches
2021-07-09 11:03 ` [Tarantool-patches] [PATCH v2 2/4] fiber: add option and PoC for Lua parent backtrace Egor Elchinov via Tarantool-patches
2021-07-12 12:09   ` Cyrill Gorcunov via Tarantool-patches [this message]
2021-07-14  9:29     ` Egor Elchinov via Tarantool-patches
2021-07-09 11:03 ` [Tarantool-patches] [PATCH v2 3/4] fiber: refactor lua backtrace routines Egor Elchinov via Tarantool-patches
2021-07-12 12:13   ` Cyrill Gorcunov via Tarantool-patches
2021-07-14  9:42     ` Egor Elchinov via Tarantool-patches
2021-07-09 11:03 ` [Tarantool-patches] [PATCH v2 4/4] fiber: refactor C backtrace and add changelog Egor Elchinov via Tarantool-patches
2021-07-12 12:35   ` Cyrill Gorcunov via Tarantool-patches
2021-07-14  9:42     ` Egor Elchinov via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YOww5+cfZum2rVTM@grain \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=elchinov.es@gmail.com \
    --cc=gorcunov@gmail.com \
    --subject='Re: [Tarantool-patches] [PATCH v2 2/4] fiber: add option and PoC for Lua parent backtrace' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox