Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, tsafin@tarantool.org,
	alyapunov@tarantool.org
Subject: [Tarantool-patches] [PATCH 07/11] test: fix signed integer overflow in vclock test
Date: Fri,  5 Jun 2020 01:43:14 +0200	[thread overview]
Message-ID: <321041c122c0450b62cc98f4795f962193a4b5c4.1591313754.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1591313754.git.v.shpilevoy@tarantool.org>

Vclock unit test had a test where all vclock components were close
to INT64_MAX. The sum was bigger than INT64_MAX, and it caused
overflow in vclock's signature.

The patch reduces order of the LSNs in this test so their sum does
not overflow anymore.

Part of #4609
---
 test/unit/vclock.cc     | 28 ++++++++++++++--------------
 test/unit/vclock.result |  2 +-
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/test/unit/vclock.cc b/test/unit/vclock.cc
index 15e9f9379..cbda7f4fc 100644
--- a/test/unit/vclock.cc
+++ b/test/unit/vclock.cc
@@ -275,20 +275,20 @@ test_tostring()
 	test(arg(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),
 	     "{1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, "
 	      "9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15}");
-	test(arg(9223372036854775000, 9223372036854775001, 9223372036854775002,
-		 9223372036854775003, 9223372036854775004, 9223372036854775005,
-		 9223372036854775006, 9223372036854775007, 9223372036854775008,
-		 9223372036854775009, 9223372036854775010, 9223372036854775011,
-		 9223372036854775012, 9223372036854775013, 9223372036854775014,
-		 9223372036854775015),
-	     "{0: 9223372036854775000, 1: 9223372036854775001, "
-	      "2: 9223372036854775002, 3: 9223372036854775003, "
-	      "4: 9223372036854775004, 5: 9223372036854775005, "
-	      "6: 9223372036854775006, 7: 9223372036854775007, "
-	      "8: 9223372036854775008, 9: 9223372036854775009, "
-	     "10: 9223372036854775010, 11: 9223372036854775011, "
-	     "12: 9223372036854775012, 13: 9223372036854775013, "
-	     "14: 9223372036854775014, 15: 9223372036854775015}");
+	test(arg(9223372054775000, 9223372054775001, 9223372054775002,
+		 9223372054775003, 9223372054775004, 9223372054775005,
+		 9223372054775006, 9223372054775007, 9223372054775008,
+		 9223372054775009, 9223372054775010, 9223372054775011,
+		 9223372054775012, 9223372054775013, 9223372054775014,
+		 9223372054775015),
+	     "{0: 9223372054775000, 1: 9223372054775001, "
+	      "2: 9223372054775002, 3: 9223372054775003, "
+	      "4: 9223372054775004, 5: 9223372054775005, "
+	      "6: 9223372054775006, 7: 9223372054775007, "
+	      "8: 9223372054775008, 9: 9223372054775009, "
+	     "10: 9223372054775010, 11: 9223372054775011, "
+	     "12: 9223372054775012, 13: 9223372054775013, "
+	     "14: 9223372054775014, 15: 9223372054775015}");
 
 	footer();
 	return check_plan();
diff --git a/test/unit/vclock.result b/test/unit/vclock.result
index 2ca741bbd..610ecbe78 100644
--- a/test/unit/vclock.result
+++ b/test/unit/vclock.result
@@ -92,7 +92,7 @@ ok 2 - subtests
     ok 5 - tostring (10, 15, 20) => {0: 10, 1: 15, 2: 20}
     ok 6 - tostring (10, -1, 15, -1, 20) => {0: 10, 2: 15, 4: 20}
     ok 7 - tostring (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) => {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15}
-    ok 8 - tostring (9223372036854775000, 9223372036854775001, 9223372036854775002, 9223372036854775003, 9223372036854775004, 9223372036854775005, 9223372036854775006, 9223372036854775007, 9223372036854775008, 9223372036854775009, 9223372036854775010, 9223372036854775011, 9223372036854775012, 9223372036854775013, 9223372036854775014, 9223372036854775015) => {0: 9223372036854775000, 1: 9223372036854775001, 2: 9223372036854775002, 3: 9223372036854775003, 4: 9223372036854775004, 5: 9223372036854775005, 6: 9223372036854775006, 7: 9223372036854775007, 8: 9223372036854775008, 9: 9223372036854775009, 10: 9223372036854775010, 11: 9223372036854775011, 12: 9223372036854775012, 13: 9223372036854775013, 14: 9223372036854775014, 15: 9223372036854775015}
+    ok 8 - tostring (9223372054775000, 9223372054775001, 9223372054775002, 9223372054775003, 9223372054775004, 9223372054775005, 9223372054775006, 9223372054775007, 9223372054775008, 9223372054775009, 9223372054775010, 9223372054775011, 9223372054775012, 9223372054775013, 9223372054775014, 9223372054775015) => {0: 9223372054775000, 1: 9223372054775001, 2: 9223372054775002, 3: 9223372054775003, 4: 9223372054775004, 5: 9223372054775005, 6: 9223372054775006, 7: 9223372054775007, 8: 9223372054775008, 9: 9223372054775009, 10: 9223372054775010, 11: 9223372054775011, 12: 9223372054775012, 13: 9223372054775013, 14: 9223372054775014, 15: 9223372054775015}
 	*** test_tostring: done ***
 ok 3 - subtests
     1..12
-- 
2.21.1 (Apple Git-122.3)

  parent reply	other threads:[~2020-06-04 23:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 23:43 [Tarantool-patches] [PATCH 00/11] Enable miscelaneous sanitations Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 01/11] cmake: enable misc types of UB detection in clang Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 10/11] sql: fix usage of not initialized index_stat Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 11/11] sql: fix mem_apply_type double type truncation Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 02/11] util: introduce double_compare_nint64() Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 03/11] test: avoid usleep() usage for error injections Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 04/11] vinyl: fix 0 division in case of canceled dump Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 05/11] xrow: don't cast double to float unconditionally Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 06/11] swim: fix zero division Vladislav Shpilevoy
2020-06-04 23:43 ` Vladislav Shpilevoy [this message]
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 08/11] digest: eliminate UBs from guava() Vladislav Shpilevoy
2020-06-04 23:43 ` [Tarantool-patches] [PATCH 09/11] salad: fix UB pointer arithmetics in bps_tree Vladislav Shpilevoy
2020-06-05 22:09 ` [Tarantool-patches] [PATCH 00/11] Enable miscelaneous sanitations Timur Safin
2020-06-09  8:19 ` Cyrill Gorcunov
2020-06-09  8:28 ` Kirill Yukhin

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=321041c122c0450b62cc98f4795f962193a4b5c4.1591313754.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=alyapunov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tsafin@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 07/11] test: fix signed integer overflow in vclock test' \
    /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