[C++] Assertion fires when trying to parse json
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
When I build (in debug) and run the code below I get the following assertion firing:
```
$ ./arrow_json
/Users/iandrus/.conan2/p/b/arrow4b55108a32d91/b/src/cpp/src/arrow/json/parser.cc:540: Check failed: (builder) == (parent.kind == Kind::kArray ? Cast(parent)->value_builder() : Cast(parent)->field_builder(field_index))
Abort trap: 6 ./arrow_json
```
Needless to say, it shouldn't abort on this, but rather fail to parse (if it's not valid—though it seems to me that it should be valid).
```
#include
#include
#include
#include
#include
#include
int main( void ) {
std::string json_data = R"json({
"all_nulls": [null, null, null]
})json";
auto buffer = std::make_shared<::arrow::Buffer>(
reinterpret_cast( json_data.data() ),
json_data.size() );
auto input = std::make_shared<::arrow::io::BufferReader>( buffer );
auto reader = ::arrow::json::TableReader::Make(
::arrow::default_memory_pool(),
input,
::arrow::json::ReadOptions::Defaults(),
::arrow::json::ParseOptions::Defaults() );
if ( !reader.ok() ) {
return 1;
}
auto result = (*reader)->Read();
return result.ok() ? 0 : 1;
}
// clang++ -o ./arrow_json ./arrow_json_main.cpp -isystem /Users/iandrus/.conan2/p/b/arrow4b55108a32d91/p/include -std=c++20 -L /Users/iandrus/.conan2/p/b/arrow4b55108a32d91/p/lib/ -larrow -larrow_bundled_dependencies -L /Users/iandrus/.conan2/p/b/snapp07bbfca910b63/p/lib/ -lsnappy -L /Users/iandrus/.conan2/p/b/zstde2aeb565ce8ea/p/lib -lzstd -L/Users/iandrus/.conan2/p/b/zlibb749ff5e66dc6/p/lib -lz
```
Changing the json to have `[null, "hi", null]` gives a different assertion. After some experimenting, the trouble seems to be the null in the first position.
```
/Users/iandrus/.conan2/p/b/arrow4b55108a32d91/b/src/cpp/src/arrow/json/parser.cc:1151: Check failed: (list_builder->value_builder()) == (builder_)
Abort trap: 6 ./arrow_json
```
### Component(s)
C++
Contributor guide
Assessment
This issue has not been assessed yet.