Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lupa/_lupa.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ cdef class _LuaObject:
def __dealloc__(self):
if self._runtime is None:
return
cdef lua_State* L = self._state
cdef lua_State* L = self._runtime._state
if L is not NULL and self._ref != lua.LUA_NOREF:
locked = lock_runtime(self._runtime)
lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
Expand Down
43 changes: 43 additions & 0 deletions lupa/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2972,6 +2972,49 @@ def test_bad_tostring(self):
def test_tostring_err(self):
self.assertRaises(lupa.LuaError, str, self.lua.eval('setmetatable({}, {__tostring = function() error() end})'))

class TestSigSegScenarios(SetupLuaRuntimeMixin, unittest.TestCase):
class PendingRequest(object):

def __init__(self, callback):
self.__callback = callback

def make_request(self, callback):
return TestSigSegScenarios.PendingRequest(callback)

def test_callback_passing(self):
self.lua.globals().make_request = self.make_request
run = self.lua.eval("""
function()
make_request(function() end)
end
""")

for i in range(10000):
thread = run.coroutine()
try:
thread.send(None)
except StopIteration:
pass

# assert no segmentation fault

def test_callback_passing_with_exception(self):
self.lua.globals().make_request = self.make_request
run = self.lua.eval("""
function()
make_request(function() end)
error('test error')
end
""")

for i in range(10000):
thread = run.coroutine()
try:
thread.send(None)
except Exception:
pass

# assert no segmentation fault

if __name__ == '__main__':
def print_version():
Expand Down