From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v1 2/3] sql: fix sql_vdbe_mem_alloc_region result memory
Date: Tue, 25 Dec 2018 19:26:29 +0200 [thread overview]
Message-ID: <A0E4617A-AF67-4F1E-B242-F0AFC00865A8@tarantool.org> (raw)
In-Reply-To: <f89b57a1bfe4d3a1c447ca9112b6d4680a41cc37.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;
> }
I’ve changed your commit message a bit:
Function sql_vdbe_mem_alloc_region() that constructs the value of Vdbe
Mem object used to change only type related flags. However, it is also
required to erase other flags (for instance flags related to allocation
policy: static, dynamic etc), since their combination may be invalid.
In a typical Vdbe scenario, OP_MakeRecord and OP_RowData release memory
with sqlite3VdbeMemRelease() and allocate on region with
sql_vdbe_mem_alloc_region(). An integrity assert based on
sqlite3VdbeCheckMemInvariants() would fire here due to incompatible
combination of flags: MEM_Static | (MEM_Blob | MEM_Ephem).
Read it and in case it looks OK to you, please apply.
LGTM.
next prev parent reply other threads:[~2018-12-25 17:26 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 ` [tarantool-patches] [PATCH v1 2/3] sql: fix sql_vdbe_mem_alloc_region result memory Kirill Shcherbatov
2018-12-25 17:26 ` n.pettik [this message]
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=A0E4617A-AF67-4F1E-B242-F0AFC00865A8@tarantool.org \
--to=korablev@tarantool.org \
--cc=kshcherbatov@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [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