Skip to content

[C++] KeyValueMetadata::DeleteMany method crashes with duplicate 0 indexes #50351

Description

@OmBiradar

Describe the bug, including details regarding any error messages, version, and platform.

When a vector<int64_t> having duplicate indexes - specifically {0,0} is passed to the KeyValueMetadata::DeleteMany method, it crashes.

It does not happen for any other numbers duplicates, rather only for 0 appearing more than once.

Script I used to test it:

void DeleteManyBugs() {
  arrow::KeyValueMetadata meta({"k1", "k2"}, {"v1", "v2"});
  Status st = meta.DeleteMany({0, 0});
  if (!st.ok()) {
    cout << "DeleteMany failed with a error status: " << st.ToString() << endl;
  }
}

int main() {
  DeleteManyBugs();
}

Output:

/usr/include/c++/16.1.1/bits/stl_vector.h:1253: constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; 
reference = std::__cxx11::basic_string<char>&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
[2]    2089238 abort (core dumped)  ./main.out

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions