From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id A24F2F35B20; Wed, 12 Feb 2025 14:36:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A24F2F35B20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1739360219; bh=Zbc755yDyIcYI71peti0U6sUV+RLx25BE8Prr5APFpA=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=pTbWj72mrFc7EDpllRCoO7w/IA7+X9jl7MgZTJ4hi3pQnCRJJFygEeVLd4g70EhaO QAujbKB31VvmFYI5tJ8hnX0PaekV/4mmXWdVWoVVgQIPT1YQZn+dpCTWwrpiAMCHQS YST9fuhRZIzTbIHqCHxYi7S40AmYjrzpOvtLy1h8= Received: from send58.i.mail.ru (send58.i.mail.ru [89.221.237.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C2BF8F35B20 for ; Wed, 12 Feb 2025 14:36:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C2BF8F35B20 Received: by exim-smtp-79fd7578cb-fh22z with esmtpa (envelope-from ) id 1tiB32-00000000XGq-2Ykx; Wed, 12 Feb 2025 14:36:57 +0300 Content-Type: multipart/alternative; boundary="------------qGSMMQJL0dZSVGYDVBZoy3sk" Message-ID: <91c49910-35f0-4177-8417-cceed99dd120@tarantool.org> Date: Wed, 12 Feb 2025 14:36:56 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <9c71b2f18bf2d3748a189591fce710a61c9a7f86.1739199089.git.sergeyb@tarantool.org> In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD93899CACFFF273C59C0084D12D4F6E6F0C6D13E9298999457182A05F5380850401BE54B90AB4E3EC43DE06ABAFEAF670555181A43FF754023560C22D47A40E0F48294EF4EEA1B5C79 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE758E3775C3D7FDEE4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BD890EF519C7ACB58638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8B8162DDF2D494411930C88BCCC244A178D98DA3B647A22CDCC7F00164DA146DAFE8445B8C89999728AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8A9FF340AA05FB58CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C251EFD5447B32ED6AD7EC71F1DB884274AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3D396008A14C5A1B9BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE75B51C8FB0C3E748C731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A595174364E3BE45395002B1117B3ED6966C8A020C255596F04A0A47EBA01A636A823CB91A9FED034534781492E4B8EEADF5E532225D4D775BBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D348B532EA2091F4FF672538506595C9FD935264C8CF8AE1FB8268E5A442F75226262EA48B75B1FA8601D7E09C32AA3244C8264E95E47752C3077DD89D51EBB774283D2186490FA8688EA455F16B58544A2E30DDF7C44BCB90DA5AE236DF995FB59978A700BF655EAEEED6A17656DB59BCAD427812AF56FC65B X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj/gRw+nncFFCrCNnZZNNA9A== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140A7BB1EC81F9BEA4B7A388D641E84891F22B2448DA8587B510152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Always close profiler output file. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------qGSMMQJL0dZSVGYDVBZoy3sk Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello, Sergey, thanks for review! Please see my comments. Updated version was force-pushed to the branch. Sergey On 11.02.2025 17:53, Sergey Kaplun via Tarantool-patches wrote: > Hi, Sergey! > Thanks for the patch! > Please consider my comments below. > > On 10.02.25, Sergey Bronnikov wrote: >> From: Mike Pall >> >> Reported by Guilherme Batalheiro. >> >> (cherry picked from commit fca66335d131669cf017420af6963a7565babb58) >> >> Before the patch, a function `prof_finish` wrote a string > Nit: s/`prof_finish`/`prof_finish()`/ > Feel free to ignore. What for? I'm already written it is a function. Ignored. >> `No samples collected` to profiler output file and then exits. > Typo: s/profiler/a profiler/ Fixed. > Typo: s/exits/exited/ Fixed. > >> Due to early exit, output file handle stay opened. This patch > Typo: s/output/the output/ > Typo: s/opened/open/ Fixed. > >> fixes condition and file handle is closed even a number of samples > Typo: s/condition/the condition/ > Typo: s/file/the file/ > Typo: s/even a number/even if the number/ Fixed. > >> is equal to 0. >> >> Sergey Bronnikov: >> * added the description and the test for the problem >> >> Part of tarantool/tarantool#11055 >> --- >> Branch:https://github.com/tarantool/luajit/tree/ligurio/gh-xxxx-close-file-profiler >> >> Related issues: >> -https://github.com/luajIT/luajIT/issues/1304 >> -https://github.com/tarantool/tarantool/issues/11055 >> >> src/jit/p.lua | 4 +-- >> ...close-profile-dump-with-0-samples.test.lua | 30 +++++++++++++++++++ >> .../script.lua | 14 +++++++++ >> test/tarantool-tests/utils/tools.lua | 4 +++ >> 4 files changed, 49 insertions(+), 3 deletions(-) >> create mode 100644 test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua >> create mode 100644 test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua >> >> diff --git a/src/jit/p.lua b/src/jit/p.lua >> index 4569d69e..89b49584 100644 >> --- a/src/jit/p.lua >> +++ b/src/jit/p.lua > > >> diff --git a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua >> new file mode 100644 >> index 00000000..b50b5fce >> --- /dev/null >> +++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua >> @@ -0,0 +1,30 @@ >> +local tap = require('tap') >> +local test = tap.test('lj-1304-close-profile-dump-with-0-samples'):skipcond({ >> + ['Test requires /proc filesystem'] = jit.os == 'OSX', > I suppose we may get off this skipcond, see the last comment. > >> +}) >> +local utils = require('utils') >> + >> +test:plan(1) >> + >> +-- Test file to demonstrate LuaJIT incorrect behaviour with missed >> +-- close a file handle for profile output file. > Typo? s/close/closing/ > Typo: s/profile/the profile/ Fixed: @@ -7,10 +7,10 @@ local utils = require('utils')  test:plan(1)  -- Test file to demonstrate LuaJIT incorrect behaviour with missed --- close a file handle for profile output file. +-- closing a file handle for the profile output file.  -- See also: https://github.com/luajIT/luajIT/issues/1304 -local p_filename = '/tmp/profile' +local p_filename = utils.tools.profilename  -- runs %testname%/script.lua by  -- with the given environment, launch options and CLI arguments. > >> +-- See also:https://github.com/luajIT/luajIT/issues/1304 >> + >> +local p_filename = '/tmp/profile' > It's better to use for the profile name generation the following > function: > | local profilename = require("utils").tools.profilename Fixed: --- a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua +++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua @@ -10,7 +10,7 @@ test:plan(1)  -- close a file handle for profile output file.  -- See also: https://github.com/luajIT/luajIT/issues/1304 -local p_filename = '/tmp/profile' +local p_filename = utils.tools.profilename  -- runs %testname%/script.lua by  -- with the given environment, launch options and CLI arguments. > >> + >> +-- runs %testname%/script.lua by >> +-- with the given environment, launch options and CLI arguments. >> +local script = utils.exec.makecmd(arg) > I don't get it. Why do we need the separate script for it? prof_finish() is executed first time on calling `jit.p.stop()` and executed second time when GC finalizer is calling [1] and therefore message "'[No samples collected]'" appears two times in the output file. 1. https://github.com/tarantool/luajit/blob/80360fb2e570ce8d54ff59ccf0bcd5dfb6b98527/src/jit/p.lua#L290 We can inline script.lua to a test body and call garbage collector manually, but I propose to leave it as is because  executing as a separate process is more real use case. > >> +-- Execute a Lua script with start and stop LuaJIT profiler, >> +-- it is expected no samples found by profiler. The script's >> +-- output is suppressed, it is not interested. >> +local _ = script(p_filename) >> + >> +local p_content = io.open(p_filename):read('a*') >> +test:is(utils.tools.trim(p_content), '[No samples collected]', >> + 'profile dump has no samples') > Minor: I suppose simple `test:like()` will be enough. In that case there > is no need to use the newly introduced `trim()` function here. The check checks that exactly one "[No samples collected]" is in a file. Before the patch, a file contains two "[No samples collected]". > >> + >> +-- Teardown. >> +os.remove(p_filename) >> + >> +test:done(true) >> diff --git a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua >> new file mode 100644 >> index 00000000..77335a08 >> --- /dev/null >> +++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua >> @@ -0,0 +1,14 @@ >> +local p_options = 'ri1' > It is better to use a much bigger interval (`i99999` for example) to be > sure that there will be no samples collected. Also, the `r` option isn't > required. Fixed: --- a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua +++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua @@ -1,6 +1,8 @@  local jit_p = require('jit.p') -local p_options = 'ri1' +-- Using a bigger interval to make sure that there will be no +-- samples collected. +local p_options = 'i99999'  local p_filename = assert(arg[1], 'filename argument is missing')  jit_p.start(p_options, p_filename) >> +local p_filename = assert(arg[1], 'filename argument is missing') >> + >> +require('jit.p').start(p_options, p_filename) >> + >> +-- No code to generate profiling samples. >> + >> +-- Stop profiler to execute `jit/p.lua:prof_fmt()`. With zero >> +-- samples it triggers early return without closing the file. >> +require('jit.p').stop() > I suppose we may require this module only once. Fixed: --- a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua +++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua @@ -1,13 +1,15 @@ +local jit_p = require('jit.p') +  local p_options = 'ri1'  local p_filename = assert(arg[1], 'filename argument is missing') -require('jit.p').start(p_options, p_filename) +jit_p.start(p_options, p_filename)  -- No code to generate profiling samples.  -- Stop profiler to execute `jit/p.lua:prof_fmt()`. With zero  -- samples it triggers early return without closing the file. -require('jit.p').stop() +jit_p.stop()  -- Make sure LuaJIT profiler is close a file handle.  local ls_output = io.popen('ls -l /proc/$$/fd'):read('a*') > >> + >> +-- Make sure LuaJIT profiler is close a file handle. >> +local ls_output = io.popen('ls -l /proc/$$/fd'):read('a*') > Minor: I am not sure that we really need this check. The descriptor will > be closed when it will be garbage collected, IINM, so there is no leak, > actually. I suggest dropping it and checking only the content of the > file -- this is the main issue regarding `jit.p` solved by that commit. This is for checking that `prof_finish` behaves correctly. fd leak is a resource leak and there is a separate CWE for this - https://cwe.mitre.org/data/definitions/775.html On my machine max number of file descriptors is 126693 per process: [0] ~ $ ulimit -n 126693 You will get file descriptor exhaustion if you will run `require('jit.p').start()` 126693 times with different output files. > > Also, in this case we can run this test on OSX. Testing on MacOS doesn't add more value, because the problem is platform-independent. > >> +assert(ls_output:find(p_filename) == nil, 'file is open') >> diff --git a/test/tarantool-tests/utils/tools.lua b/test/tarantool-tests/utils/tools.lua >> index 33fcae78..9cb65daf 100644 >> --- a/test/tarantool-tests/utils/tools.lua >> +++ b/test/tarantool-tests/utils/tools.lua >> @@ -21,4 +21,8 @@ function M.read_file(path) >> return content >> end >> >> +function M.trim(str) >> + return (str:gsub('^%s*(.-)%s*$', '%1')) >> +end >> + >> return M >> -- >> 2.34.1 >> --------------qGSMMQJL0dZSVGYDVBZoy3sk Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hello, Sergey,

thanks for review! Please see my comments.

Updated version was force-pushed to the branch.

Sergey

On 11.02.2025 17:53, Sergey Kaplun via Tarantool-patches wrote:
Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

On 10.02.25, Sergey Bronnikov wrote:
From: Mike Pall <mike>

Reported by Guilherme Batalheiro.

(cherry picked from commit fca66335d131669cf017420af6963a7565babb58)

Before the patch, a function `prof_finish` wrote a string
Nit: s/`prof_finish`/`prof_finish()`/
Feel free to ignore.
What for? I'm already written it is a function. Ignored.

      
`No samples collected` to profiler output file and then exits.
Typo: s/profiler/a profiler/
Fixed.
Typo: s/exits/exited/
Fixed.

Due to early exit, output file handle stay opened. This patch
Typo: s/output/the output/
Typo: s/opened/open/
Fixed.

fixes condition and file handle is closed even a number of samples
Typo: s/condition/the condition/
Typo: s/file/the file/
Typo: s/even a number/even if the number/
Fixed.

is equal to 0.

Sergey Bronnikov:
* added the description and the test for the problem

Part of tarantool/tarantool#11055
---
Branch: https://github.com/tarantool/luajit/tree/ligurio/gh-xxxx-close-file-profiler

Related issues:
- https://github.com/luajIT/luajIT/issues/1304
- https://github.com/tarantool/tarantool/issues/11055

 src/jit/p.lua                                 |  4 +--
 ...close-profile-dump-with-0-samples.test.lua | 30 +++++++++++++++++++
 .../script.lua                                | 14 +++++++++
 test/tarantool-tests/utils/tools.lua          |  4 +++
 4 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua
 create mode 100644 test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua

diff --git a/src/jit/p.lua b/src/jit/p.lua
index 4569d69e..89b49584 100644
--- a/src/jit/p.lua
+++ b/src/jit/p.lua
<snipped>

diff --git a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua
new file mode 100644
index 00000000..b50b5fce
--- /dev/null
+++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua
@@ -0,0 +1,30 @@
+local tap = require('tap')
+local test = tap.test('lj-1304-close-profile-dump-with-0-samples'):skipcond({
+  ['Test requires /proc filesystem'] = jit.os == 'OSX',
I suppose we may get off this skipcond, see the last comment.

+})
+local utils = require('utils')
+
+test:plan(1)
+
+-- Test file to demonstrate LuaJIT incorrect behaviour with missed
+-- close a file handle for profile output file.
Typo? s/close/closing/
Typo: s/profile/the profile/

Fixed:

@@ -7,10 +7,10 @@ local utils = require('utils')
 test:plan(1)
 
 -- Test file to demonstrate LuaJIT incorrect behaviour with missed
--- close a file handle for profile output file.
+-- closing a file handle for the profile output file.
 -- See also: https://github.com/luajIT/luajIT/issues/1304
 
-local p_filename = '/tmp/profile'
+local p_filename = utils.tools.profilename
 
 -- <makecmd> runs %testname%/script.lua by <LUAJIT_TEST_BINARY>
 -- with the given environment, launch options and CLI arguments.


+-- See also: https://github.com/luajIT/luajIT/issues/1304
+
+local p_filename = '/tmp/profile'
It's better to use for the profile name generation the following
function:
| local profilename = require("utils").tools.profilename

Fixed:


--- a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua
+++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.test.lua
@@ -10,7 +10,7 @@ test:plan(1)
 -- close a file handle for profile output file.
 -- See also: https://github.com/luajIT/luajIT/issues/1304
 
-local p_filename = '/tmp/profile'
+local p_filename = utils.tools.profilename
 
 -- <makecmd> runs %testname%/script.lua by <LUAJIT_TEST_BINARY>
 -- with the given environment, launch options and CLI arguments.

+
+-- <makecmd> runs %testname%/script.lua by <LUAJIT_TEST_BINARY>
+-- with the given environment, launch options and CLI arguments.
+local script = utils.exec.makecmd(arg)
I don't get it. Why do we need the separate script for it?


prof_finish() is executed first time on calling `jit.p.stop()`

and executed second time when GC finalizer is calling [1] and therefore message "'[No samples collected]'" appears

two times in the output file.

1. https://github.com/tarantool/luajit/blob/80360fb2e570ce8d54ff59ccf0bcd5dfb6b98527/src/jit/p.lua#L290


We can inline script.lua to a test body and call garbage collector manually,

but I propose to leave it as is because  executing as a separate process is more real use case.


+-- Execute a Lua script with start and stop LuaJIT profiler,
+-- it is expected no samples found by profiler. The script's
+-- output is suppressed, it is not interested.
+local _ = script(p_filename)
+
+local p_content = io.open(p_filename):read('a*')
+test:is(utils.tools.trim(p_content), '[No samples collected]',
+        'profile dump has no samples')
Minor: I suppose simple `test:like()` will be enough. In that case there
is no need to use the newly introduced `trim()` function here.

The check checks that exactly one "[No samples collected]" is in a file.

Before the patch, a file contains two "[No samples collected]".


+
+-- Teardown.
+os.remove(p_filename)
+
+test:done(true)
diff --git a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua
new file mode 100644
index 00000000..77335a08
--- /dev/null
+++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua
@@ -0,0 +1,14 @@
+local p_options = 'ri1'
It is better to use a much bigger interval (`i99999` for example) to be
sure that there will be no samples collected. Also, the `r` option isn't
required.

Fixed:

--- a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua
+++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua
@@ -1,6 +1,8 @@
 local jit_p = require('jit.p')
 
-local p_options = 'ri1'
+-- Using a bigger interval to make sure that there will be no
+-- samples collected.
+local p_options = 'i99999'
 local p_filename = assert(arg[1], 'filename argument is missing')
 
 jit_p.start(p_options, p_filename)


      
+local p_filename = assert(arg[1], 'filename argument is missing')
+
+require('jit.p').start(p_options, p_filename)
+
+-- No code to generate profiling samples.
+
+-- Stop profiler to execute `jit/p.lua:prof_fmt()`. With zero
+-- samples it triggers early return without closing the file.
+require('jit.p').stop()
I suppose we may require this module only once.

Fixed:

--- a/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua
+++ b/test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.lua
@@ -1,13 +1,15 @@
+local jit_p = require('jit.p')
+
 local p_options = 'ri1'
 local p_filename = assert(arg[1], 'filename argument is missing')
 
-require('jit.p').start(p_options, p_filename)
+jit_p.start(p_options, p_filename)
 
 -- No code to generate profiling samples.
 
 -- Stop profiler to execute `jit/p.lua:prof_fmt()`. With zero
 -- samples it triggers early return without closing the file.
-require('jit.p').stop()
+jit_p.stop()
 
 -- Make sure LuaJIT profiler is close a file handle.
 local ls_output = io.popen('ls -l /proc/$$/fd'):read('a*')


+
+-- Make sure LuaJIT profiler is close a file handle.
+local ls_output = io.popen('ls -l /proc/$$/fd'):read('a*')
Minor: I am not sure that we really need this check. The descriptor will
be closed when it will be garbage collected, IINM, so there is no leak,
actually. I suggest dropping it and checking only the content of the
file -- this is the main issue regarding `jit.p` solved by that commit.

This is for checking that `prof_finish` behaves correctly.

fd leak is a resource leak and there is a separate CWE for this -

https://cwe.mitre.org/data/definitions/775.html

On my machine max number of file descriptors is 126693 per process:

[0] ~ $ ulimit -n
126693

You will get file descriptor exhaustion if you will run

`require('jit.p').start()` 126693 times with different output files.


Also, in this case we can run this test on OSX.
Testing on MacOS doesn't add more value, because the problem is platform-independent.

+assert(ls_output:find(p_filename) == nil, 'file is open')
diff --git a/test/tarantool-tests/utils/tools.lua b/test/tarantool-tests/utils/tools.lua
index 33fcae78..9cb65daf 100644
--- a/test/tarantool-tests/utils/tools.lua
+++ b/test/tarantool-tests/utils/tools.lua
@@ -21,4 +21,8 @@ function M.read_file(path)
   return content
 end
 
+function M.trim(str)
+  return (str:gsub('^%s*(.-)%s*$', '%1'))
+end
+
 return M
-- 
2.34.1


    
--------------qGSMMQJL0dZSVGYDVBZoy3sk--