Skip to content

numpy::from_data calls vector::front and crashes (or has UB) when called with a scalar object #526

Description

@mborgerding

In ndarray.cpp, the function from_data_impl calls &shape.front() and &strides.front() for possibly empty vectors. This is, at best, undefined behavior. At worst, it triggers a crash (observed on Redhat/rocky 8&9, where I'm assuming boost::python packages were built with -D_GLIBCXX_DEBUG).

RECOMMEND: change &vec.front() to vec.data() to avoid UB and potential crashes.

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