Skip to content

DEBUG_LEVEL=0 Build failure #13166

@arramesh42

Description

@arramesh42

DEBUG_LEVEL=0 build is broken ?!

I have the main tree at commit: 6f9d826

If I run below command:
DEBUG_LEVEL=0 make -j48 db_bench

compilation fails with following error:

=======================

In file included from memtable/wbwi_memtable.cc:6:
./memtable/wbwi_memtable.h: In member function ‘void rocksdb::WBWIMemTableIterator::UpdateKey()’:
./memtable/wbwi_memtable.h:127:49: error: array subscript 0 is outside array bounds of ‘std::aligned_storage<8, 4>::type [0]’ [-Werror=array-bounds=]
127 | std::to_string(t->second));
| ~~~^~~~~~
cc1plus: note: source object is likely at address zero

======================

Looks like it is complaining because we are trying to access t->second after verifying that
t == WriteTypeToValueTypeMap.end(). (Basically t has reached end, at this point)

This seems to be introduced from below commit.

=========================
commit id: 1c7652f
Author: Changyu Bi changyubi@meta.com
Date: Tue Nov 12 09:27:11 2024 -0800

Introduce a WriteBatchWithIndex-based implementation of ReadOnlyMemTable (#13123)

Summary:
introduce the class WBWIMemTable that implements ReadOnlyMemTable interface with data stored in a WriteBatchWithIndex object.

========================

However, compilation does not fail if DEBUG_LEVEL=1.

The following change fixes the compilation error.

$ git diff
diff --git a/memtable/wbwi_memtable.h b/memtable/wbwi_memtable.h
index 1daf5d779..b48abf993 100644
--- a/memtable/wbwi_memtable.h
+++ b/memtable/wbwi_memtable.h
@@ -122,8 +122,7 @@ class WBWIMemTableIterator final : public InternalIterator {
     if (t == WriteTypeToValueTypeMap.end()) {
       key_.clear();
       valid_ = false;
-      s_ = Status::Corruption("Unexpected write_batch_with_index entry type " +
-                              std::to_string(t->second));
+      s_ = Status::Corruption("Unexpected write_batch_with_index entry type.");
       return;
     }
     key_buf_.SetInternalKey(it_->Entry().key, global_seqno_, t->second);

I can send a PR if above change is acceptable.

Although I am a little bit surprised that the nightly builds haven't caught this. Or please let me know if I am missing something here.

Expected behavior: Build should pass

Actual behavior: Build fails (DEBUG_LEVEL=0)

Steps to reproduce the behavior: Run "DEBUG_LEVEL=0 make -j48 db_bench"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions