Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: tarantool-patches@freelists.org
Subject: [PATCH] vinyl: fix crash in run iterator due to uninitialized variable
Date: Sat, 23 Feb 2019 00:17:30 +0300	[thread overview]
Message-ID: <79bd523e8551f665c9d2b85c37e42ff809c7ba10.1550870228.git.vdavydov.dev@gmail.com> (raw)

vy_run_iterator_seek left the return statement uninitialized under
certain conditions. The branch in the code wasn't covered by any test,
because it could only be triggered by an EQ SELECT following range
coalescing, so we only saw it when a customer reported a crash.
Fix it and improve vinyl/select_consistency test to cover this branch.
---
 src/box/vy_run.c                       |  1 +
 test/vinyl/select_consistency.result   | 14 ++++++++++++--
 test/vinyl/select_consistency.test.lua | 14 ++++++++++++--
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/box/vy_run.c b/src/box/vy_run.c
index 14975bdf..38ca686f 100644
--- a/src/box/vy_run.c
+++ b/src/box/vy_run.c
@@ -1363,6 +1363,7 @@ vy_run_iterator_seek(struct vy_run_iterator *itr,
 		cmp = vy_stmt_compare_with_key(key, slice->begin, cmp_def);
 		if (cmp < 0 && iterator_type == ITER_EQ) {
 			vy_run_iterator_stop(itr);
+			*ret = NULL;
 			return 0;
 		}
 		if (cmp < 0 || (cmp == 0 && iterator_type != ITER_GT)) {
diff --git a/test/vinyl/select_consistency.result b/test/vinyl/select_consistency.result
index c8f19cac..f27d0ec6 100644
--- a/test/vinyl/select_consistency.result
+++ b/test/vinyl/select_consistency.result
@@ -53,10 +53,20 @@ end;
 ---
 ...
 function dml_loop()
+    local insert = true
     while not stop do
-        gen_insert()
+        if s:len() >= MAX_KEY then
+            insert = false
+        end
+        if s:len() <= MAX_KEY / 2 then
+            insert = true
+        end
+        if insert then
+            gen_insert()
+        else
+            gen_delete()
+        end
         gen_update()
-        gen_delete()
         fiber.sleep(0)
     end
     ch:put(true)
diff --git a/test/vinyl/select_consistency.test.lua b/test/vinyl/select_consistency.test.lua
index 90fcf67e..73b443e8 100644
--- a/test/vinyl/select_consistency.test.lua
+++ b/test/vinyl/select_consistency.test.lua
@@ -34,10 +34,20 @@ function gen_update()
 end;
 
 function dml_loop()
+    local insert = true
     while not stop do
-        gen_insert()
+        if s:len() >= MAX_KEY then
+            insert = false
+        end
+        if s:len() <= MAX_KEY / 2 then
+            insert = true
+        end
+        if insert then
+            gen_insert()
+        else
+            gen_delete()
+        end
         gen_update()
-        gen_delete()
         fiber.sleep(0)
     end
     ch:put(true)
-- 
2.11.0

             reply	other threads:[~2019-02-22 21:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 21:17 Vladimir Davydov [this message]
2019-02-22 21:17 ` Vladimir Davydov
2019-02-23  9:54   ` [tarantool-patches] " Konstantin Osipov

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=79bd523e8551f665c9d2b85c37e42ff809c7ba10.1550870228.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH] vinyl: fix crash in run iterator due to uninitialized variable' \
    /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