[BUG]: `FileMetaData.c_obj` can be null and segfault on dereference
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
`FileMetaData` has no `__cinit__` that default-constructs `c_obj`, so any instance created via
`FileMetaData.__new__(FileMetaData)` (bypassing `__init__`, which raises) has a null `c_obj`.
Any `dereference(self.c_obj)` call then segfaults instead of raising a Python exception:
https://github.com/NVIDIA/cudf/blob/d4ecacec0cbdcb420a786416ff3b9e50111f0ca9/python/pylibcudf/pylibcudf/io/parquet_metadata.pyx#L473-L480
Previously `c_obj` was an embedded (non-pointer) value and could not be null, so this is a
regression in safety introduced by PR #23558 (which switched `FileMetaData` to hold a
`unique_ptr` so it could be shared/reused, e.g. from `hybrid_scan.pyx`).
`Scalar` has the same `unique_ptr` + `from_libcudf`-only pattern elsewhere in pylibcudf, so this
may be worth fixing generally rather than just for `FileMetaData`.
## Related
- PR #23558 (introduced the `unique_ptr` change)
- https://github.com/NVIDIA/cudf/pull/23558#discussion_r3739313433
Contributor guide
Research direction
Start in python/pylibcudf/pylibcudf/io/parquet_metadata.pyx around lines 473-480 and review PR #23558 to understand the unique_ptr change. Check how FileMetaData instances created through __new__ behave, then compare the related Scalar pattern; done means invalid instances raise a Python exception instead of segfaulting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100