<HTML><BODY><div>Hi!</div><div>Thanks for the review!<br>Here is the answer from the «Programming in Lua» (3rd edition), paragraph 32.2:<div><div>> From Lua we use the collectgarbage function: collectgarbage(what [, data])</div><div>> Both offer the same functionality. The what argument (an enumeration value in C, a string in Lua) specifies what to do. The > options are:</div><div><snipped></div><div>> LUA_GCCOLLECT (“collect”): performs a complete garbage-collection cycle, so that all unreachable objects are collected and finalized. This is the default option for collectgarbage.</div></div></div><div> </div><div data-signature-widget="container"><div data-signature-widget="content"><div>--<br>Best regards,</div><div>Maxim Kokryashkin</div></div></div><div> </div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Суббота, 18 ноября 2023, 19:52 +03:00 от Sergey Bronnikov <sergeyb@tarantool.org>:<br> <div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_17003263741012334475_BODY">Hello, Max<br><br>LGTM with a question below<br><br><br>On 11/9/23 16:45, Maksim Kokryashkin wrote:<br>> This test could do allocation outside of the protected frame,<br>> which could result in an uncaught OOM and test failure. This<br>> patch adds extra `collectgarbage` calls to the test to avoid<br>> such situations.<br>> ---<br>> Changes in v2:<br>> - Fixed comments as per review by Sergey Kaplun<br>> Branch: <a href="https://github.com/tarantool/luajit/tree/fckxorg/lj-1004-fix-flaky" target="_blank">https://github.com/tarantool/luajit/tree/fckxorg/lj-1004-fix-flaky</a><br>> PR: <a href="https://github.com/tarantool/tarantool/pull/9318" target="_blank">https://github.com/tarantool/tarantool/pull/9318</a><br>> test/tarantool-tests/lj-1004-oom-error-frame.test.lua | 7 +++++++<br>> 1 file changed, 7 insertions(+)<br>><br>> diff --git a/test/tarantool-tests/lj-1004-oom-error-frame.test.lua b/test/tarantool-tests/lj-1004-oom-error-frame.test.lua<br>> index 3be6b555..2ddb5765 100644<br>> --- a/test/tarantool-tests/lj-1004-oom-error-frame.test.lua<br>> +++ b/test/tarantool-tests/lj-1004-oom-error-frame.test.lua<br>> @@ -10,6 +10,8 @@ test:plan(2)<br>><br>> local testoomframe = require('testoomframe')<br>><br>> +collectgarbage()<br><br>Probably it is obvious, but I don't get it.<br><br>Usually for forcing garbage collecting one need call `collectgarbage()`<br>two times:<br><br>for mark and sweep. You call it single time, why?<br><br><br>> +<br>> local anchor_memory = {} -- luacheck: no unused<br>> local function eatchunks(size)<br>> while true do<br>> @@ -34,6 +36,11 @@ local function chomp()<br>> end<br>><br>> local st, err = pcall(chomp)<br>> +<br>> +-- Prevent OOM outside of the protected frame.<br>> +anchor_memory = nil<br>> +collectgarbage()<br>Ditto.<br>> +<br>> test:ok(st == false, 'on-trace error handled successfully')<br>> test:like(err, 'not enough memory', 'error is OOM')<br>> test:done(true)<br>> --<br>> 2.39.3 (Apple Git-145)<br>></div></div></div></div></blockquote><div> </div></BODY></HTML>