From a785e029f7cf1f7e00e597e989957c52af91d6e0 Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Mon, 12 Nov 2012 13:50:55 -0800 Subject: [PATCH] The db_bench utility was broken in 1.5.4.fb because of a signed-unsigned comparision. Summary: The db_bench utility was broken in 1.5.4.fb because of a signed-unsigned comparision. The static variable FLAGS_min_level_to_compress was recently changed from int to 'unsigned in' but it is initilized to a nagative value -1. The segfault is of this type: Program received signal SIGSEGV, Segmentation fault. Open (this=0x7fffffffdee0) at db/db_bench.cc:939 939 db/db_bench.cc: No such file or directory. (gdb) where Test Plan: run db_bench with no options. Reviewers: heyongqiang Reviewed By: heyongqiang CC: MarkCallaghan, emayanke, sheki Differential Revision: https://reviews.facebook.net/D6663 --- db/db_bench.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/db_bench.cc b/db/db_bench.cc index 9054d890e..3726c1ed6 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -181,7 +181,7 @@ static enum leveldb::CompressionType FLAGS_compression_type = // Allows compression for levels 0 and 1 to be disabled when // other levels are compressed -static unsigned int FLAGS_min_level_to_compress = -1; +static int FLAGS_min_level_to_compress = -1; static int FLAGS_table_cache_numshardbits = 4; @@ -942,7 +942,7 @@ class Benchmark { if (FLAGS_min_level_to_compress >= 0) { assert(FLAGS_min_level_to_compress <= FLAGS_num_levels); options.compression_per_level = new CompressionType[FLAGS_num_levels]; - for (unsigned int i = 0; i < FLAGS_min_level_to_compress; i++) { + for (int i = 0; i < FLAGS_min_level_to_compress; i++) { options.compression_per_level[i] = kNoCompression; } for (unsigned int i = FLAGS_min_level_to_compress; -- GitLab