Skip to content

[C++] Segmentation fault in ExecBatchBuilder #39583

@zanmato1984

Description

@zanmato1984

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

This is a subsequent issue of #32570.

In the last fix #39234, I didn't realize there were similar issue for fixed size types.

I am now able to produce the segmentation fault using fixed size types, listed in the following UT:

TEST(ExecBatchBuilder, AppendBatchDupRowsFixedSize) {
  std::unique_ptr<MemoryPool> owned_pool = MemoryPool::CreateDefault();
  MemoryPool* pool = owned_pool.get();
  {
    // 63-byte data occupying almost one minimal 64-byte aligned memory region.
    ExecBatch batch_fsb = JSONToExecBatch({fixed_size_binary(9)}, R"([
        ["000000000"],
        ["000000000"],
        ["000000000"],
        ["000000000"],
        ["000000000"],
        ["000000000"],
        ["123456789"]])");  // 9-byte tail row, not aligned to a word.
    ASSERT_EQ(batch_fsb[0].array()->buffers[1]->capacity(), 64);
    ExecBatchBuilder builder;
    uint16_t row_ids[2] = {6, 6};
    ASSERT_OK(builder.AppendSelected(pool, batch_fsb, 2, row_ids, /*num_cols=*/1));
    ExecBatch built = builder.Flush();
    ExecBatch batch_fsb_appended =
        JSONToExecBatch({fixed_size_binary(9)}, R"([["123456789"], ["123456789"]])");
    ASSERT_EQ(batch_fsb_appended, built);
    ASSERT_NE(0, pool->bytes_allocated());
  }
  ASSERT_EQ(0, pool->bytes_allocated());
}

Component(s)

C++

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions