boostorg / boostorg/python

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

Ouverte Adaptée aux débutants
#526 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
537
Forks
223
Merge moyen
11 h 22 min
PR mergées (30 j)
2

Description

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Start in ndarray.cpp at from_data_impl, where shape.front() and strides.front() are used for potentially empty vectors. Reproduce or inspect the scalar-object path and verify that it no longer performs invalid access or crashes; run the repository’s relevant existing tests if available. Done means scalar from_data calls work without undefined behavior or the reported crash.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cpp
Domaine
backend
Type d'issue
Bug
Difficulté
1/5
Temps estimé
Moins d'une heure
Activité
Calme
Clarté
Clairement spécifiée
Accessibilité débutants
84/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.