See this line in LuaTests.m:
result = [ctx call:"setPublicPr" with:@[ @5 ] error:&error];
It invokes the following Lua code:
function setPublicPr (v)
ex.publicString = v
print(v)
return v
end
The Lua engine will throw an error in the line ex.publicString = v because of incompatible types.
The problem is that this will add a reference to the ex object, which will result in a leak.
I've tried to figure out why this happens, and which part of the code causes the leak but wasn't successfuly. I found that it's related to throwing an error in the code outlined in issue #9, though. If no error is raised, then there's no leak. Since the Lua code uses setjmp() to exit from deep code throwing an error, there is no unwinding of intermediate states happening, though. I suspect that some intermediate caller between the LUAI_TRY in luaD_rawrunprotected and the call of lua_error(L) in luaWrapperNewIndex needs to do some cleanup.
If ARC is disabled and the few objects are instead manually retained and released, the issue does not occur, even if the above error is thrown.
See this line in LuaTests.m:
It invokes the following Lua code:
The Lua engine will throw an error in the line
ex.publicString = vbecause of incompatible types.The problem is that this will add a reference to the
exobject, which will result in a leak.I've tried to figure out why this happens, and which part of the code causes the leak but wasn't successfuly. I found that it's related to throwing an error in the code outlined in issue #9, though. If no error is raised, then there's no leak. Since the Lua code uses setjmp() to exit from deep code throwing an error, there is no unwinding of intermediate states happening, though. I suspect that some intermediate caller between the
LUAI_TRYinluaD_rawrunprotectedand the call oflua_error(L)inluaWrapperNewIndexneeds to do some cleanup.If ARC is disabled and the few objects are instead manually retained and released, the issue does not occur, even if the above error is thrown.