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: Thu, 6 Mar 2025 19:19:00 +0300 [thread overview] Message-ID: <99f54bbebab5e38184294664a944b3cc314cb140.1741277815.git.sergeyb@tarantool.org> (raw) In-Reply-To: <cover.1741277815.git.sergeyb@tarantool.org> When sysprof is not started the function `misc.sysprof.stop()` reports that the profiler is already running: | $ ./src/luajit -e 'print(misc.sysprof.stop())' | nil profiler is running already 22 The patch fixes that: | $ ./src/luajit -e 'print(misc.sysprof.stop())' | nil profiler is not running 22 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 1c81fd80..88ae9e10 100644 --- a/src/lib_misc.c +++ b/src/lib_misc.c @@ -336,6 +336,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 91ea461b..f316c390 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 @@ -123,7 +123,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
next prev parent reply other threads:[~2025-03-06 16:21 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-03-06 16:18 [Tarantool-patches] [PATCH luajit 0/3] Fix sysprof error on stop not started sysprof Sergey Bronnikov via Tarantool-patches 2025-03-06 16:18 ` [Tarantool-patches] [PATCH luajit 1/3] sysprof: rename sysprof_error to prof_error Sergey Bronnikov via Tarantool-patches 2025-03-06 16:18 ` [Tarantool-patches] [PATCH luajit 2/3] misc: use prof_error for handling errors Sergey Bronnikov via Tarantool-patches 2025-03-07 7:18 ` Sergey Kaplun via Tarantool-patches 2025-03-06 16:19 ` Sergey Bronnikov via Tarantool-patches [this message] 2025-03-07 7:21 ` [Tarantool-patches] [PATCH luajit 3/3] sysprof: fix a message with stop without run Sergey Kaplun via Tarantool-patches 2025-03-07 10:44 ` Sergey Bronnikov via Tarantool-patches -- strict thread matches above, loose matches on Subject: below -- 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 3/3] sysprof: fix a message with stop without run Sergey Bronnikov via Tarantool-patches 2025-03-05 14:52 ` Sergey Kaplun via Tarantool-patches 2025-03-06 15:18 ` 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=99f54bbebab5e38184294664a944b3cc314cb140.1741277815.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