Tarantool development patches archive
 help / color / mirror / Atom feed
From: Maksim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org, sergos@tarantool.org,
	skaplun@tarantool.org, m.kokryashkin@tarantool.org
Cc: Maksim Kokryashkin <max.kokryashkin@gmail.com>
Subject: [Tarantool-patches] [PATCH luajit] codehealth: fix sign extension in sysprof counters
Date: Tue, 14 Mar 2023 18:25:07 +0300	[thread overview]
Message-ID: <20230314152507.37168-1-max.kokryashkin@gmail.com> (raw)

The `setnumfield` function takes `int64_t` as an argument.
Profile counters used to have the `uint64_t` type before
this patch, which could lead to issues with sign extension.
Now their type is `int64_t`, so they correspond to the
`setnumfield` argument type.
---
PR: https://github.com/tarantool/tarantool/pull/8440
Branch: https://github.com/tarantool/luajit/tree/fckxorg/svace-sysprof-report
 src/lj_sysprof.c |  2 +-
 src/lmisclib.h   | 22 +++++++++++-----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/lj_sysprof.c b/src/lj_sysprof.c
index 2e9ed9b3..4723e6f9 100644
--- a/src/lj_sysprof.c
+++ b/src/lj_sysprof.c
@@ -285,7 +285,7 @@ static void sysprof_record_sample(struct sysprof *sp, siginfo_t *info)
   lua_assert(pthread_self() == sp->thread);
 
   /* Caveat: order of counters must match vmstate order in <lj_obj.h>. */
-  ((uint64_t *)&sp->counters)[vmstate]++;
+  ((int64_t *)&sp->counters)[vmstate]++;
 
   sp->counters.samples++;
 
diff --git a/src/lmisclib.h b/src/lmisclib.h
index 9084319c..599a6ea9 100644
--- a/src/lmisclib.h
+++ b/src/lmisclib.h
@@ -105,21 +105,21 @@ typedef void (*luam_Sysprof_backtracer)(void *(*frame_writer)(int frame_no, void
 #define LUAM_SYSPROF_CALLGRAPH 2
 
 struct luam_Sysprof_Counters {
-  uint64_t vmst_interp;
-  uint64_t vmst_lfunc;
-  uint64_t vmst_ffunc;
-  uint64_t vmst_cfunc;
-  uint64_t vmst_gc;
-  uint64_t vmst_exit;
-  uint64_t vmst_record;
-  uint64_t vmst_opt;
-  uint64_t vmst_asm;
-  uint64_t vmst_trace;
+  int64_t vmst_interp;
+  int64_t vmst_lfunc;
+  int64_t vmst_ffunc;
+  int64_t vmst_cfunc;
+  int64_t vmst_gc;
+  int64_t vmst_exit;
+  int64_t vmst_record;
+  int64_t vmst_opt;
+  int64_t vmst_asm;
+  int64_t vmst_trace;
   /*
   ** XXX: Order of vmst counters is important: it should be the same as the
   ** order of the vmstates.
   */
-  uint64_t samples;
+  int64_t samples;
 };
 
 /* Profiler options. */
-- 
2.37.1 (Apple Git-137.1)


             reply	other threads:[~2023-03-14 15:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 15:25 Maksim Kokryashkin via Tarantool-patches [this message]
2023-03-15  6:48 ` Sergey Kaplun 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=20230314152507.37168-1-max.kokryashkin@gmail.com \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=m.kokryashkin@tarantool.org \
    --cc=max.kokryashkin@gmail.com \
    --cc=sergos@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit] codehealth: fix sign extension in sysprof counters' \
    /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