GH-41306: [C++] Check to avoid copying when NullBitmapBuffer is Null (#41452)



### Rationale for this change

This PR addresses a bug with the `FixedSizeBinary` type where it does not cast to a `Binary` type after being sliced. When slicing occurs, the offset is modified. If the resulting sliced data structure does not contain any `null` values, the Null Bitmap Buffer may be set to `null`.

Currently, when a `Cast` operation is attempted on such a data structure, the code erroneously tries to access the Null Bitmap Buffer even when it is `null`. This leads to an `EXC_BAD_ACCESS` error. This PR implements a fix to prevent this erroneous behavior by adding checks before accessing the Null Bitmap Buffer.

### What changes are included in this PR?

- Add a null check for the Null Bitmap Buffer when casting from `FixedSizeBinary` to `Binary` to prevent access violations if the buffer is null.

### Are these changes tested?

Yes

### Are there any user-facing changes?

Yes (Pyarrow side)

* GitHub Issue: #41306

Authored-by: Hyunseok Seo <hsseo0501@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
2 files changed
tree: d281fef20d4c2a60bbda96d4d77174df21a119b0
  1. .github/
  2. .mvn/
  3. c_glib/
  4. ci/
  5. cpp/
  6. csharp/
  7. dev/
  8. docs/
  9. format/
  10. go/
  11. java/
  12. js/
  13. matlab/
  14. python/
  15. r/
  16. ruby/
  17. swift/
  18. .asf.yaml
  19. .clang-format
  20. .clang-tidy
  21. .clang-tidy-ignore
  22. .dir-locals.el
  23. .dockerignore
  24. .env
  25. .gitattributes
  26. .gitignore
  27. .gitmodules
  28. .hadolint.yaml
  29. .pre-commit-config.yaml
  30. .readthedocs.yml
  31. appveyor.yml
  32. CHANGELOG.md
  33. cmake-format.py
  34. CODE_OF_CONDUCT.md
  35. CONTRIBUTING.md
  36. docker-compose.yml
  37. header
  38. LICENSE.txt
  39. NOTICE.txt
  40. README.md
README.md

Apache Arrow

Fuzzing Status License Twitter Follow

Powering In-Memory Analytics

Apache Arrow is a development platform for in-memory analytics. It contains a set of technologies that enable big data systems to process and move data fast.

Major components of the project include:

Arrow is an Apache Software Foundation project. Learn more at arrow.apache.org.

What's in the Arrow libraries?

The reference Arrow libraries contain many distinct software components:

  • Columnar vector and table-like containers (similar to data frames) supporting flat or nested types
  • Fast, language agnostic metadata messaging layer (using Google's Flatbuffers library)
  • Reference-counted off-heap buffer memory management, for zero-copy memory sharing and handling memory-mapped files
  • IO interfaces to local and remote filesystems
  • Self-describing binary wire formats (streaming and batch/file-like) for remote procedure calls (RPC) and interprocess communication (IPC)
  • Integration tests for verifying binary compatibility between the implementations (e.g. sending data from Java to C++)
  • Conversions to and from other in-memory data structures
  • Readers and writers for various widely-used file formats (such as Parquet, CSV)

Implementation status

The official Arrow libraries in this repository are in different stages of implementing the Arrow format and related features. See our current feature matrix on git main.

How to Contribute

Please read our latest project contribution guide.

Getting involved

Even if you do not plan to contribute to Apache Arrow itself or Arrow integrations in other projects, we'd be happy to have you involved: