apache / apache/arrow

[C++] Crash when build arrow::Array using arrow::ArrayBuilder

Open
#30,504 2 comments 0 reactions 0 assignees View on GitHub
Component: C++ Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

Reproduce process:
BTW, after using this PR, the crash disappeared.

```cpp

int main()
{
auto value_field = arrow::field("value", arrow::utf8(), false);
auto map_field = arrow::field("evenInfo", arrow::map(arrow::utf8(), value_field), false);
auto map_type = std::dynamic_pointer_cast(map_field->type());
std::cout << "field:" << map_field->ToString() << std::endl;
std::cout << "key_type: " << map_type->key_type()->ToString() << std::endl;
std::cout << "val_type: " << map_type->value_type()->ToString() << std::endl;
std::cout << "item_type: " << map_type->item_type()->ToString() << std::endl;

arrow::MemoryPool * pool = arrow::default_memory_pool();
std::unique_ptr array_builder;
arrow::Status status = MakeBuilder(pool, map_field->type(), &array_builder);
std::shared_ptr arrow_array;
status = array_builder->Finish(&arrow_array);
std::cout << status.ToString() << std::endl;
return 0;
}
```

error log:
```bash

Check failed: self->list_type_->value_type()->Equals(data->child_data[0]->type)
```
crash backtrace as below:

```bash

#0 0x00007fcdd893118b in raise () from /usr/lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007fcdd893118b in raise () from /usr/lib/x86_64-linux-gnu/libc.so.6
#1 0x00007fcdd8910859 in abort () from /usr/lib/x86_64-linux-gnu/libc.so.6
#2 0x000000000e39c209 in arrow::util::CerrLog::~CerrLog() ()
#3 0x000000000e39c239 in arrow::util::CerrLog::~CerrLog() ()
#4 0x000000000e39be90 in arrow::util::ArrowLog::~ArrowLog() ()
#5 0x000000000d93ddf0 in void arrow::internal::SetListData(arrow::BaseListArray*, std::__1::shared_ptr const&, arrow::Type::type) ()
#6 0x000000000d935e4d in arrow::MapArray::SetData(std::__1::shared_ptr const&) ()
#7 0x000000000d935c13 in arrow::MapArray::MapArray(std::__1::shared_ptr const&) ()
#8 0x000000000d9cab30 in std::__1::__shared_ptr_emplace >::__shared_ptr_emplace const&>(std::__1::allocator, std::__1::shared_ptr const&) ()
#9 0x000000000d9caa2f in std::__1::shared_ptr std::__1::allocate_shared, std::__1::shared_ptr const&, void>(std::__1::allocator const&, std::__1::shared_ptr const&) ()
#10 0x000000000d9ca9ae in std::__1::shared_ptr std::__1::make_shared const&, void>(std::__1::shared_ptr const&) ()
#11 0x000000000d9bd20f in arrow::Status arrow::(anonymous namespace)::ArrayDataWrapper::Visit(arrow::MapType const&) ()
#12 0x000000000d9aebfb in arrow::Status arrow::VisitTypeInline(arrow::DataType const&, arrow::(anonymous namespace)::ArrayDataWrapper*) ()
#13 0x000000000d9ae2e2 in arrow::MakeArray(std::__1::shared_ptr const&) ()
#14 0x000000000d94d62f in arrow::ArrayBuilder::Finish(std::__1::shared_ptr*) ()
```

**Environment**: $ uname -a
Linux sg-ch-test006.bigdata.bigo.inner 4.9.70-040970-generic #201712161132 SMP Sat Dec 16 16:33:52 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
**Reporter**: [liyang](https://issues.apache.org/jira/browse/ARROW-14983)
#### Related issues:
- [[Python] Creating a Map array with non-default field names segfaults](https://github.com/apache/arrow/issues/29368) (duplicates)

**Note**: *This issue was originally created as [ARROW-14983](https://issues.apache.org/jira/browse/ARROW-14983). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Contributor guide

Open the contributing guide

Research direction

Start with the supplied C++ reproducer and trace ArrayBuilder::Finish through MakeArray, MapArray::SetData, and SetListData, using the backtrace to locate the map child-type check. Done means the reproducer no longer aborts when finishing a map builder with the shown field names, while the map data types remain consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
data-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.