From 0ca691654f24ff42ee5ca1ddb802419dba3e2c17 Mon Sep 17 00:00:00 2001 From: Jay Huh Date: Fri, 18 Oct 2024 07:31:54 -0700 Subject: [PATCH] Fix Unit Test failing from uninit values in CompactionServiceInput (#13080) Summary: # Summary There was a [test failure](https://github.com/facebook/rocksdb/actions/runs/11381731053/job/31663774089?fbclid=IwZXh0bgNhZW0CMTEAAR0YJVdnkKUhN15RJQrLsvicxqzReS6y4A14VFQbWu-81XJsSsyNepXAr2c_aem_JyQqNdtpeKFSA6CjlD-pDg) from uninit value in the CompactionServiceInput ``` [ RUN ] CompactionJobTest.InputSerialization ==79945== Use of uninitialised value of size 8 ==79945== at 0x58EA69B: _itoa_word (_itoa.c:179) ==79945== by 0x5906574: __vfprintf_internal (vfprintf-internal.c:1687) ==79945== by 0x591AF99: __vsnprintf_internal (vsnprintf.c:114) ==79945== by 0x1654AE: std::__cxx11::basic_string, std::allocator > __gnu_cxx::__to_xstring, std::allocator >, char>(int (*)(char*, unsigned long, char const*, __va_list_tag*), unsigned long, char const*, ...) (string_conversions.h:111) ==79945== by 0x5126C65: to_string (basic_string.h:6568) ==79945== by 0x5126C65: rocksdb::SerializeSingleOptionHelper(void const*, rocksdb::OptionType, std::__cxx11::basic_string, std::allocator >*) (options_helper.cc:541) ==79945== by 0x512718B: rocksdb::OptionTypeInfo::Serialize(rocksdb::ConfigOptions const&, std::__cxx11::basic_string, std::allocator > const&, void const*, std::__cxx11::basic_string, std::allocator >*) const (options_helper.cc:1084) ``` This was due to `options_file_number` value not set in the unit test. However, this value is guaranteed to be set in the normal path. It was just missing in the test path. Setting the 0 as the default value for uninitialized fields in the `CompactionServiceInput` and `CompactionServiceResult` for now. Pull Request resolved: https://github.com/facebook/rocksdb/pull/13080 Test Plan: Existing tests should be sufficient Reviewed By: cbi42 Differential Revision: D64573567 Pulled By: jaykorean fbshipit-source-id: 7843a951770c74445620623d069a52ba93ad94d5 --- db/compaction/compaction_job.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/compaction/compaction_job.h b/db/compaction/compaction_job.h index 69895eac38..e266babda5 100644 --- a/db/compaction/compaction_job.h +++ b/db/compaction/compaction_job.h @@ -386,7 +386,7 @@ struct CompactionServiceInput { // files needed for this compaction, for both input level files and output // level files. std::vector input_files; - int output_level; + int output_level = 0; // db_id is used to generate unique id of sst on the remote compactor std::string db_id; @@ -397,7 +397,7 @@ struct CompactionServiceInput { bool has_end = false; std::string end; - uint64_t options_file_number; + uint64_t options_file_number = 0; // serialization interface to read and write the object static Status Read(const std::string& data_str, CompactionServiceInput* obj); @@ -454,7 +454,7 @@ struct CompactionServiceOutputFile { struct CompactionServiceResult { Status status; std::vector output_files; - int output_level; + int output_level = 0; // location of the output files std::string output_path;