From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id D1F136EC57; Sat, 20 Mar 2021 03:42:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D1F136EC57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616200969; bh=RhKgaZ7uIPKpudOigw4DkubycTf/9saR8ODmujxFyyw=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sZHjsthpGMsRcqoeONkTCVMp6/B1FQ8uV9jA7+UMFUNKnnJmkK552wW7ihp7JRLGr UqhcPEUSfmdqoxXMkM4Qwi8BEBlalzO05rC2qxsmfn5WxvvZdNlYJcuGMtqbsO0LNb J4IuN4veC2LEVhY8miwdeI7phA1fuiQCqWajPi1s= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1EE966EC56 for ; Sat, 20 Mar 2021 03:42:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1EE966EC56 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lNPhX-00076U-Ni; Sat, 20 Mar 2021 03:42:48 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Sat, 20 Mar 2021 01:42:30 +0100 Message-Id: X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD95D6E7CC48CB1F5F146FB1591D6F88157B67AD80B9C5634CD182A05F538085040B247CC67424C37EE0A9382A74F9906CA85D5F25CB271EC687888FB62186313FD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F09446BC3D835A58EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C558246F87AE15468638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C81A23F326053F8278B7E4276C13A14A4D6C05D364641072AA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE709B92020B71E24959FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C390BCC82C2C62A6D1117882F4460429728AD0CFFFB425014E868A13BD56FB6657A7F4EDE966BC389F9E8FC8737B5C2249753C3A5E0A5AB5B7089D37D7C0E48F6CCF19DD082D7633A0E7DDDDC251EA7DABAAAE862A0553A39223F8577A6DFFEA7C831C17AB68599A1243847C11F186F3C5E7DDDDC251EA7DABCC89B49CDF41148F90DBEB212AEC08F22623479134186CDE6BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2BBE337FB72E923155C0AF1600DCBC20BD3311767B7455A330B088AAC5B3AE5DC X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C81A23F326053F8278B7E4276C13A14A4D6C05D364641072A9C2B6934AE262D3EE7EAB7254005DCED28564988FAA543729510FB958DCE06DB6ED91DBE5ABE359ADBCB5631A0A9D21F1B2EFE7B39F7738393EDB24507CE13387DFF0A840B692CF8 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34753B45383CEFF204688D7FC7906119390E406CDE0FD956BBDAA1AC26E41A69A956867EB1FF1AE1FE1D7E09C32AA3244C5228EC6761CF2385C0E60ECD1B8074B939C99C45E8D137E9FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj8xHC0Ak4ylY17ny9bwwreA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638226F5958E64566499965EE3CC8E11CF3AA3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 00/16] Cord buffer, static alloc, and Lua GC bug X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" The patch attempts to fix most of the easy to face issues with the global resources not having proper ownership in Lua code and therefore not protected again being suddenly reused during Lua GC. There are many such resources: tarantool_lua_ibuf/IBUF_SHARED, static alloc, errno, diag/box.error, box_tuple_last, port_c, and others. The most easy to screw - ibuf and static alloc. They are fixed in this patchset. The solution is dubious, but there were not found any better alternatives. A patch for 1.10 will be sent later in a separate CL. Branch: http://github.com/tarantool/tarantool/tree/gerold103/gh-5632-global-buf-crash-2x Issue: https://github.com/tarantool/tarantool/issues/5632 Vladislav Shpilevoy (16): fio: don't use shared buffer in pread() test: don't use IBUF_SHARED in the tests tuple: pass global ibuf explicitly where possible iconv: take errno before reseting the context cord_buf: introduce cord_buf API cord_buf: introduce ownership management buffer: implement ffi stash uuid: replace static_alloc with ffi stash uuid: drop tt_uuid_str() from Lua uri: replace static_alloc with ffi stash and ibuf buffer: remove static_alloc() from Lua lua: use lua_pushfstring() instead of tt_sprintf() sio: rework sio_strfaddr() sio: increase SERVICE_NAME_MAXLEN size sio: introduce and use sio_snprintf() buffer: remove Lua registers changelogs/unreleased/fix-ibuf-static.md | 7 + src/CMakeLists.txt | 1 - src/box/iproto.cc | 8 +- src/box/iproto.h | 2 +- src/box/lua/info.c | 5 +- src/box/lua/net_box.lua | 4 +- src/box/lua/schema.lua | 56 ++++-- src/box/lua/session.c | 7 +- src/box/lua/space.cc | 6 +- src/box/lua/tuple.c | 80 +++++---- src/box/lua/tuple.lua | 14 +- src/exports.h | 7 +- src/lib/core/CMakeLists.txt | 1 + src/lib/core/cord_buf.c | 167 ++++++++++++++++++ src/lib/core/cord_buf.h | 54 ++++++ src/lib/core/sio.c | 72 ++++---- src/lib/core/sio.h | 15 +- src/lua/buffer.c | 42 ----- src/lua/buffer.lua | 156 +++++++++------- src/lua/crypto.lua | 19 +- src/lua/digest.lua | 25 ++- src/lua/fiber.c | 2 +- src/lua/fio.lua | 12 +- src/lua/iconv.lua | 27 +-- src/lua/init.c | 3 - src/lua/msgpack.c | 6 +- src/lua/msgpackffi.lua | 57 +++--- src/lua/socket.lua | 54 +++--- src/lua/string.lua | 26 ++- src/lua/swim.lua | 19 +- src/lua/uri.lua | 21 ++- src/lua/utf8.c | 21 ++- src/lua/utils.h | 1 - src/lua/uuid.lua | 115 +++++++----- .../test/static-build/exports.test.lua | 4 +- test/app-tap/buffer.test.lua | 59 +++++++ test/app-tap/gh-5632-gc-buf-reuse.test.lua | 151 ++++++++++++++++ test/app-tap/module_api.test.lua | 10 +- test/app-tap/uri.test.lua | 23 +-- test/app/buffer.result | 53 ------ test/app/buffer.test.lua | 23 --- test/app/fio.result | 160 +++++++++-------- test/app/fio.test.lua | 67 ++++--- test/app/msgpack.result | 7 +- test/app/msgpack.test.lua | 5 +- test/box/varbinary_type.result | 3 +- test/box/varbinary_type.test.lua | 3 +- test/unit/luaT_tuple_new.c | 4 - 48 files changed, 1092 insertions(+), 592 deletions(-) create mode 100644 changelogs/unreleased/fix-ibuf-static.md create mode 100644 src/lib/core/cord_buf.c create mode 100644 src/lib/core/cord_buf.h delete mode 100644 src/lua/buffer.c create mode 100755 test/app-tap/buffer.test.lua create mode 100755 test/app-tap/gh-5632-gc-buf-reuse.test.lua delete mode 100644 test/app/buffer.result delete mode 100644 test/app/buffer.test.lua -- 2.24.3 (Apple Git-128)