Skip to content

[BUG]: FileMetaData.c_obj can be null and segfault on dereference #23679

Description

@Matt711

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:

def __init__(self):
raise ValueError("FileMetaData cannot be constructed directly")
@staticmethod
cdef FileMetaData from_libcudf(unique_ptr[cpp_FileMetaData] metadata):
cdef FileMetaData result = FileMetaData.__new__(FileMetaData)
result.c_obj = move(metadata)
return result

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions