Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] [PATCH v1 2/3] sql: fix sql_vdbe_mem_alloc_region result memory
Date: Wed, 19 Dec 2018 18:37:24 +0300	[thread overview]
Message-ID: <f89b57a1bfe4d3a1c447ca9112b6d4680a41cc37.1545233551.git.kshcherbatov@tarantool.org> (raw)
In-Reply-To: <cover.1545233551.git.kshcherbatov@tarantool.org>

The function sql_vdbe_mem_alloc_region that constructing the
value of Vdbe Mem object used to change only flags responsible
for it's type.
It is also required to grind old flags, as their combination may
be invalid.
In a typical Vdbe scenario, OP_MakeRecord and OP_RowData make
memory release with sqlite3VdbeMemRelease and allocation
on region with sql_vdbe_mem_alloc_region call. An integrity
assert based on sqlite3VdbeCheckMemInvariants would fire here
because of contradictory combination of flags
MEM_Static | (MEM_Blob | MEM_Ephem).

Needed for #3850
---
 src/box/sql/vdbeaux.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index fc805e3aa..d477662a4 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -3231,7 +3231,8 @@ sql_vdbe_mem_alloc_region(Mem *vdbe_mem, uint32_t size)
 	vdbe_mem->z = region_alloc(&fiber()->gc, size);
 	if (vdbe_mem->z == NULL)
 		return SQLITE_NOMEM;
-	MemSetTypeFlag(vdbe_mem, MEM_Blob | MEM_Ephem);
+	vdbe_mem->flags = MEM_Ephem | MEM_Blob;
+	assert(sqlite3VdbeCheckMemInvariants(vdbe_mem));
 	return SQLITE_OK;
 }
 
-- 
2.19.2

  parent reply	other threads:[~2018-12-19 15:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 15:37 [tarantool-patches] [PATCH v1 0/3] sql: do not use OP_Delete+OP_Insert for UPDATES Kirill Shcherbatov
2018-12-19 15:37 ` [tarantool-patches] [PATCH v1 1/3] sql: clean-up vdbe_emit_constraint_checks Kirill Shcherbatov
2018-12-25 17:26   ` [tarantool-patches] " n.pettik
2018-12-19 15:37 ` Kirill Shcherbatov [this message]
2018-12-25 17:26   ` [tarantool-patches] Re: [PATCH v1 2/3] sql: fix sql_vdbe_mem_alloc_region result memory n.pettik
2018-12-19 15:37 ` [tarantool-patches] [PATCH v1 3/3] sql: do not use OP_Delete+OP_Insert for UPDATES Kirill Shcherbatov
2018-12-25 17:26   ` [tarantool-patches] " n.pettik
2018-12-26  8:35     ` Kirill Shcherbatov
2018-12-28 14:17       ` n.pettik
2018-12-20 20:41 ` [tarantool-patches] Re: [PATCH v1 0/3] " Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f89b57a1bfe4d3a1c447ca9112b6d4680a41cc37.1545233551.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH v1 2/3] sql: fix sql_vdbe_mem_alloc_region result memory' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox