From d93e1fcea482f8348bb42171befea08466f8541f Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 10 Jun 2024 09:57:47 +0200 Subject: Suspend/resume GC around Linda operations --- src/linda.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/linda.cpp b/src/linda.cpp index e4ae3f4..81926f9 100644 --- a/src/linda.cpp +++ b/src/linda.cpp @@ -180,6 +180,11 @@ int Linda::ProtectedCall(lua_State* L_, lua_CFunction f_) if (_K == nullptr) return 0; + // no GC allowed during the call, because we don't want to trigger collection of another linda + // bound to the same keeper, as that would cause a deadlock when trying to acquire it while + // doing LindaFactory::deleteDeepObjectInternal -> keeper_call(clear) + lua_gc(L_, LUA_GCSTOP, 0); + LUA_ASSERT_CODE(auto const _koip{ _linda->startKeeperOperation(L_) }); // if we didn't do anything wrong, the keeper stack should be clean LUA_ASSERT(L_, lua_gettop(_K) == 0); @@ -192,6 +197,9 @@ int Linda::ProtectedCall(lua_State* L_, lua_CFunction f_) // whatever happens, the keeper state stack must be empty when we are done lua_settop(_K, 0); + // restore normal GC operations + lua_gc(L_, LUA_GCRESTART, 0); + // release the keeper _linda->releaseKeeper(_keeper); -- cgit v1.2.3-55-g6feb