Skip to content

Thread Safety Bug in DictionaryArray::dictionary() #49064

@AliRana30

Description

@AliRana30

Problem:
Race condition in cpp/src/arrow/array/array_dict.cc line 112. The dictionary() method does lazy initialization without locks - multiple threads can simultaneously see dictionary_ as null and both try to initialize, causing memory corruption or double-free.

Location:
cpp/src/arrow/array/array_dict.cc lines 110-116

const std::shared_ptr<Array>& DictionaryArray::dictionary() const {
  if (!dictionary_) {
    // TODO(GH-36503) this isn't thread safe
    dictionary_ = MakeArray(data_->dictionary);
  }
  return dictionary_;
}

### Component(s)

C++

Metadata

Metadata

Assignees

Type

No type
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