[tarantool-patches] [PATCH] Fix tuple cdata collecting

Georgy Kirichenko georgy at tarantool.org
Thu Oct 25 12:58:37 MSK 2018


In some cases luajit does not collect cdata objects which where
transformed with ffi.cast as tuple_bless does. In consequence, internal
table with gc callback overflows and then lua crashes. There might be an
internal luajit issue because it fires only for jitted code. But assigning
a gc callback before transformation fixes the problem.

Fixes: #3751
---
https://github.com/tarantool/tarantool/issues/3751
https://github.com/tarantool/tarantool/tree/g.kirichenko/gh-3751-fix-luajit-cdata-gc

 src/box/lua/tuple.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/box/lua/tuple.lua b/src/box/lua/tuple.lua
index 63ea73e43..8662a3a02 100644
--- a/src/box/lua/tuple.lua
+++ b/src/box/lua/tuple.lua
@@ -100,7 +100,7 @@ local tuple_bless = function(tuple)
     -- overflow checked by tuple_bless() in C
     builtin.box_tuple_ref(tuple)
     -- must never fail:
-    return ffi.gc(ffi.cast(const_tuple_ref_t, tuple), tuple_gc)
+    return ffi.cast(const_tuple_ref_t, ffi.gc(tuple, tuple_gc))
 end
 
 local tuple_check = function(tuple, usage)
-- 
2.19.1





More information about the Tarantool-patches mailing list