forked from LuaJIT/LuaJIT
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sysprof: disable proto and trace dumps in default
There is no need to dump proto or trace information for sysprof in the default mode. Moreover, attempts to do so will lead to segmentation fault due to uninitialized buffer. This commit disables proto and trace dumps in the default mode. Resolves tarantool/tarantool#7264 Reviewed-by: Sergey Kaplun <skaplun@tarantool.org> Reviewed-by: Igor Munkin <imun@tarantool.org> Signed-off-by: Igor Munkin <imun@tarantool.org>
- Loading branch information
1 parent
36b4b80
commit 1019a57
Showing
2 changed files
with
51 additions
and
2 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
49 changes: 49 additions & 0 deletions
49
test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua
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,49 @@ | ||
-- Sysprof is implemented for x86 and x64 architectures only. | ||
require('utils').skipcond( | ||
jit.arch ~= 'x86' and jit.arch ~= 'x64' or jit.os ~= 'Linux' | ||
or require('ffi').abi('gc64'), | ||
jit.arch..' architecture or '..jit.os.. | ||
' OS is NIY for sysprof' | ||
) | ||
|
||
local tap = require('tap') | ||
local test = tap.test('gh-7264-add-proto-trace-sysprof-default.test.lua') | ||
test:plan(2) | ||
|
||
local chunk = [[ | ||
return function() | ||
local a = 'teststring' | ||
end | ||
]] | ||
|
||
local function allocate() | ||
local a = {} | ||
for _ = 1, 3 do | ||
table.insert(a, 'teststring') | ||
end | ||
return a | ||
end | ||
|
||
-- Proto creation during the sysprof runtime. | ||
jit.off() | ||
|
||
assert(misc.sysprof.start({ mode = 'D' })) | ||
-- The first call yields the anonymous function created by loading | ||
-- <chunk> proto. As a result the child proto function is yielded. | ||
-- The second call invokes the child proto function to trigger | ||
-- <lj_sysprof_add_proto> call. | ||
assert(load(chunk))()() | ||
test:ok(misc.sysprof.stop(), 'new proto in sysprof runtime') | ||
|
||
-- Trace creation during the sysprof runtime. | ||
jit.flush() | ||
jit.opt.start('hotloop=1') | ||
jit.on() | ||
|
||
assert(misc.sysprof.start({ mode = 'D' })) | ||
-- Run <allocate> function to record a new trace. As a result, | ||
-- <lj_sysprof_add_trace> is triggered to be invoked. | ||
allocate() | ||
test:ok(misc.sysprof.stop(), 'trace record in sysprof runtime') | ||
|
||
os.exit(test:check() and 0 or 1) |