numpy::from_data calls vector::front and crashes (or has UB) when called with a scalar object
- Vorherrschende Sprache
- C++
- Sterne
- 537
- Forks
- 223
- Ø Merge
- 11 Std. 22 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Aktivitätsstatus
- Ruhig
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 84/100