[Tarantool-patches] [PATCH luajit 3/3] sysprof: fix a message with stop without run
Sergey Bronnikov
estetus at gmail.com
Tue Feb 25 10:32:50 MSK 2025
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
More information about the Tarantool-patches
mailing list