Skip to content

Commit

Permalink
sysprof: fix a message with stop without run
Browse files Browse the repository at this point in the history
The function `misc.sysprof.stop()` reports that profiler is
already running:

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

The patch fixes that.
  • Loading branch information
ligurio committed Feb 4, 2025
1 parent 5dd3f91 commit b49c5fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lj_sysprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ int lj_sysprof_stop(lua_State *L)
global_State *g = sp->g;
struct lj_wbuf *out = &sp->out;

if (SPS_IDLE == sp->state)
if (SPS_PROFILE != sp->state)
return PROFILE_ERRRUN;
else if (G(L) != g)
return PROFILE_ERRUSE;
Expand Down
5 changes: 3 additions & 2 deletions test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local test = tap.test("misc-sysprof-lapi"):skipcond({
["Disabled due to #10803"] = os.getenv("LUAJIT_TEST_USE_VALGRIND"),
})

test:plan(33)
test:plan(34)

jit.off()
-- XXX: Run JIT tuning functions in a safe frame to avoid errors
Expand Down Expand Up @@ -98,7 +98,8 @@ assert(res, err)

-- Not running.
res, err, errno = misc.sysprof.stop()
test:ok(res == nil and err, "res and error with not running")
test:is(res, nil, "res with not running")
test:ok(err:match("profiler is running already"), "error with not running")
test:ok(type(errno) == "number", "errno with not running")

-- Bad path.
Expand Down

0 comments on commit b49c5fa

Please sign in to comment.