Skip to content

[C++] Assertion fires when trying to parse json #47417

Closed

Description

@gvol

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<Kind::kArray>(parent)->value_builder() : Cast<Kind::kObject>(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 <arrow/buffer.h>
#include <arrow/io/api.h>
#include <arrow/json/api.h>
#include <arrow/status.h>

#include <memory>
#include <string>

int main( void ) {
    std::string json_data = R"json({
        "all_nulls": [null, null, null]
    })json";

    auto buffer = std::make_shared<::arrow::Buffer>(
            reinterpret_cast<uint8_t const *>( 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++

Activity

  1. added a commit that references this issue on Sep 3, 2026
  2. added 2 commits that reference this issue on Oct 22, 2026
  3. added a commit that references this issue on Oct 26, 2026
  4. added this to the 27.0.0 milestone on Oct 26, 2026
  5. pitrou commented on Oct 26, 2026

    @pitrou
    Member

    Issue resolved by pull request 51108
    #51108

  6. pitrou commented on Oct 26, 2026

    @pitrou
    Member

    @advitrocks9 Can you post a comment here so that we can assign this issue to you?

  7. advitrocks9 commented on Oct 26, 2026

    @advitrocks9
    Contributor
  8. modified the milestones: 27.0.0, 26.0.1 on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions