Skip to content

Large arrays casting of unicode/bytes cast to quaddtype leads segfault #237

@SwayamInSync

Description

@SwayamInSync
import numpy as np
from numpy_quaddtype import QuadPrecDType

arr = np.arange(501, dtype=QuadPrecDType())
arr.astype('U50')

# output
# Segmentation fault (core dumped)

Interesting part is this happens as size > 500 i.e. segfaults for 501 and ahead
This seems more of a GIL issue as per docs functions like PyUnicode_FromString should be called with GIL held and this issue get resolved when we additionally register the loops with NPY_METH_REQUIRES_PYAPI flag.

Should we take this as a fix? I saw StringDType also uses this flag in casting spec

cc: @ngoldbaum @seberg

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions