[Tarantool-patches] [PATCH luajit v2] test: fix flaky OOM error frame test

Maxim Kokryashkin m.kokryashkin at tarantool.org
Sun Nov 19 14:49:14 MSK 2023


Hi!
Thanks for the review!
Here is the answer from the «Programming in Lua» (3rd edition), paragraph 32.2:
> From Lua we use the collectgarbage function: collectgarbage(what [, data])
> Both offer the same functionality. The what argument (an enumeration value in C, a string in Lua) specifies what to do. The > options are:
<snipped>
> 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.
 
--
Best regards,
Maxim Kokryashkin
 
  
>Суббота, 18 ноября 2023, 19:52 +03:00 от Sergey Bronnikov <sergeyb at tarantool.org>:
> 
>Hello, Max
>
>LGTM with a question below
>
>
>On 11/9/23 16:45, Maksim Kokryashkin wrote:
>> This test could do allocation outside of the protected frame,
>> which could result in an uncaught OOM and test failure. This
>> patch adds extra `collectgarbage` calls to the test to avoid
>> such situations.
>> ---
>> Changes in v2:
>> - Fixed comments as per review by Sergey Kaplun
>> Branch:  https://github.com/tarantool/luajit/tree/fckxorg/lj-1004-fix-flaky
>> PR:  https://github.com/tarantool/tarantool/pull/9318
>> test/tarantool-tests/lj-1004-oom-error-frame.test.lua | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/test/tarantool-tests/lj-1004-oom-error-frame.test.lua b/test/tarantool-tests/lj-1004-oom-error-frame.test.lua
>> index 3be6b555..2ddb5765 100644
>> --- a/test/tarantool-tests/lj-1004-oom-error-frame.test.lua
>> +++ b/test/tarantool-tests/lj-1004-oom-error-frame.test.lua
>> @@ -10,6 +10,8 @@ test:plan(2)
>>
>> local testoomframe = require('testoomframe')
>>
>> +collectgarbage()
>
>Probably it is obvious, but I don't get it.
>
>Usually for forcing garbage collecting one need call `collectgarbage()`
>two times:
>
>for mark and sweep. You call it single time, why?
>
>
>> +
>> local anchor_memory = {} -- luacheck: no unused
>> local function eatchunks(size)
>> while true do
>> @@ -34,6 +36,11 @@ local function chomp()
>> end
>>
>> local st, err = pcall(chomp)
>> +
>> +-- Prevent OOM outside of the protected frame.
>> +anchor_memory = nil
>> +collectgarbage()
>Ditto.
>> +
>> test:ok(st == false, 'on-trace error handled successfully')
>> test:like(err, 'not enough memory', 'error is OOM')
>> test:done(true)
>> --
>> 2.39.3 (Apple Git-145)
>>
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20231119/9f675f19/attachment.htm>


More information about the Tarantool-patches mailing list