forked from LuaJIT/LuaJIT
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sysprof: fix crash during FFUNC stream
Sometimes, the Lua stack can be inconsistent during the FFUNC execution, which may lead to a sysprof crash during the stack unwinding. This patch replaces the `top_frame` property of `global_State` with `lj_sysprof_topframe` structure, which contains `top_frame` and `ffid` properties. `ffid` property makes sense only when the LuaJIT VM state is set to `FFUNC`. That property is set to the ffid of the fast function that VM is about to execute. In the same time, `top_frame` property is not updated now, so the top frame of the Lua stack can be streamed based on the ffid, and the rest of the Lua stack can be streamed as usual. Resolves tarantool/tarantool#8594
- Loading branch information
1 parent
8ddd7bc
commit bb35f7b
Showing
5 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
local tap = require('tap') | ||
local test = tap.test('gh-8594-sysprof-ffunc-crash'):skipcond({ | ||
['Sysprof is implemented for x86_64 only'] = jit.arch ~= 'x86' and | ||
jit.arch ~= 'x64', | ||
['Sysprof is implemented for Linux only'] = jit.os ~= "Linux", | ||
}) | ||
|
||
test:plan(1) | ||
|
||
jit.off() | ||
-- XXX: Run JIT tuning functions in a safe frame to avoid errors | ||
-- thrown when LuaJIT is compiled with JIT engine disabled. | ||
pcall(jit.flush) | ||
|
||
local TMP_BINFILE = '/dev/null' | ||
|
||
local res, err = misc.sysprof.start{ | ||
mode = 'C', | ||
interval = 3, | ||
path = TMP_BINFILE, | ||
} | ||
assert(res, err) | ||
|
||
for i = 1, 1e5 do | ||
tostring(i) | ||
end | ||
|
||
res, err = misc.sysprof.stop() | ||
assert(res, err) | ||
|
||
test:ok(true, 'sysprof finished successfully') | ||
|
||
os.exit(test:check() and 0 or 1) |