Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org,
	Sergey Kaplun <skaplun@tarantool.org>
Subject: [Tarantool-patches] [PATCH luajit 3/3] sysprof: fix a message with stop without run
Date: Tue, 25 Feb 2025 10:32:50 +0300	[thread overview]
Message-ID: <ff864572c8acae3a58379fd3175acc4dadecbc41.1740468394.git.sergeyb@tarantool.org> (raw)
In-Reply-To: <cover.1740468394.git.sergeyb@tarantool.org>

The function `misc.sysprof.stop()` reports that profiler is
already running:

| $ ./src/luajit -e 'print(misc.sysprof.stop())'
| nil     profiler is running already     22

both in `sysprof_error()` and fixes aforementioned problem.

Follows up tarantool/tarantool#781
---
 src/lib_misc.c                                              | 6 ++++++
 .../tarantool-tests/profilers/misclib-sysprof-lapi.test.lua | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/lib_misc.c b/src/lib_misc.c
index c4b40996..74888d20 100644
--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -335,6 +335,12 @@ LJLIB_CF(misc_sysprof_stop)
   return prof_error(L, PROFILE_ERRUSE, err_details);
 #else
   int status = luaM_sysprof_stop(L);
+  if (LJ_UNLIKELY(status == PROFILE_ERRRUN)) {
+      lua_pushnil(L);
+      lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING));
+      lua_pushinteger(L, EINVAL);
+      return 3;
+  }
   if (LJ_UNLIKELY(status != PROFILE_SUCCESS))
     return prof_error(L, status, NULL);
 
diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
index ebd80cf6..770b5736 100644
--- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
+++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
@@ -10,7 +10,7 @@ local test = tap.test("misclib-sysprof-lapi"):skipcond({
   ["Disabled due to #10803"] = os.getenv("LUAJIT_TEST_USE_VALGRIND"),
 })
 
-test:plan(43)
+test:plan(44)
 
 jit.off()
 -- XXX: Run JIT tuning functions in a safe frame to avoid errors
@@ -124,7 +124,8 @@ assert(res, err)
 
 -- Not running.
 res, err, errno = misc.sysprof.stop()
-test:ok(res == nil and err, "result status and error with not running")
+test:is(res, nil, "result status with not running")
+test:ok(err:match("profiler is not running"), "error with not running")
 test:ok(type(errno) == "number", "errno with not running")
 
 -- Bad path.
-- 
2.43.0


  parent reply	other threads:[~2025-02-25  7:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25  7:32 [Tarantool-patches] [PATCH luajit 0/3] Fix sysprof error on stop not started sysprof Sergey Bronnikov via Tarantool-patches
2025-02-25  7:32 ` [Tarantool-patches] [PATCH luajit 1/3] sysprof: rename sysprof_error to prof_error Sergey Bronnikov via Tarantool-patches
2025-03-05 14:28   ` Sergey Kaplun via Tarantool-patches
2025-02-25  7:32 ` [Tarantool-patches] [PATCH luajit 2/3] misc: use prof_error for handling errors Sergey Bronnikov via Tarantool-patches
2025-03-05 14:49   ` Sergey Kaplun via Tarantool-patches
2025-03-06 16:04     ` Sergey Bronnikov via Tarantool-patches
2025-02-25  7:32 ` Sergey Bronnikov via Tarantool-patches [this message]
2025-03-05 14:52   ` [Tarantool-patches] [PATCH luajit 3/3] sysprof: fix a message with stop without run Sergey Kaplun via Tarantool-patches
2025-03-06 15:18     ` Sergey Bronnikov via Tarantool-patches
2025-03-12 11:11 ` [Tarantool-patches] [PATCH luajit 0/3] Fix sysprof error on stop not started sysprof Sergey Kaplun via Tarantool-patches
2025-03-06 16:18 Sergey Bronnikov via Tarantool-patches
2025-03-06 16:19 ` [Tarantool-patches] [PATCH luajit 3/3] sysprof: fix a message with stop without run Sergey Bronnikov via Tarantool-patches
2025-03-07  7:21   ` Sergey Kaplun via Tarantool-patches
2025-03-07 10:44     ` Sergey Bronnikov 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=ff864572c8acae3a58379fd3175acc4dadecbc41.1740468394.git.sergeyb@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=estetus@gmail.com \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 3/3] sysprof: fix a message with stop without run' \
    /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