[BUG]: Function with Param of type `const Eigen::VectorXd&` causes "windows fatal exception: access violation" on Windows
Los mantenedores suelen responder en 4 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Área
- backend-api-design
Línea de trabajo
Comienza con el módulo pybind11 reproducible y compara el parámetro set_data como const Eigen::VectorXd& frente a Eigen::Ref con las versiones indicadas de Windows, Visual Studio, Python y pybind11. Rastrea el comportamiento de conversión a través de la ruta incluida pybind11/eigen.h y compáralo con la stable branch. Se considera terminado cuando se haya identificado la causa de la infracción de acceso y se haya definido o aplicado una corrección verificada en todos los entornos indicados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
v2.10.4
Problem description
When calling function with parameter const Eigen::VectorXd&, it fails with "windows fatal exception: access violation" on Windows, compiled with VS2022, Python 3.12, and Pybind v2.10.4.
However, the example works well with Python 3.10 + VS2019 + Pybind v2.10.4.
Besides, it also works well in Python 3.12 + VS2022 + Pybind current stable branch.
I know from the Documentation that it recommend using Eigen::Ref for reference. Using Eigen::Ref, Python 3.12 + VS2022 + Pybind v2.10.4 also works.
That said, using either Pybind current stable branch or Eigen::Ref can make it work.
I have been struggling on this issue for a while.
I want to understand how things go wrong:
- Why
Eigen::Refworks, butconst Eigen::VectorXd¬? - Why Pybind current stable branch works?
Reproducible example code
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/functional.h>
#include <pybind11/eigen.h>
#include <pybind11/stl.h>
#include <vector>
#include <Eigen/Eigen>
namespace py = pybind11;
class ArrayDynamic {
using Vector =Eigen::VectorXd;
private:
Vector data_;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
ArrayDynamic() = default;
virtual ~ArrayDynamic() = default;
explicit ArrayDynamic(size_t dim) { data_.resize(dim); }
auto data() const -> const Vector& { return data_; }
auto data() -> Vector& { return data_; }
};
PYBIND11_MODULE(promote, m)
{
auto math = m.def_submodule("math");
py::class_<ArrayDynamic>(math, "ArrayDynamic")
.def(py::init<size_t>(), "Create an array of given size.", py::arg("dim"))
.def("data", py::overload_cast<>(&ArrayDynamic::data), py::return_value_policy::reference_internal, "internal")
.def( "set_data",
[](ArrayDynamic& array,
const Eigen::VectorXd& data)
{
array.data() = data;
},
"Set data.");
}
For a full example, see https://github.com/huweiATgithub/pybind_fail_example
### Is this a regression? Put the last known working version here if it is.
Not a regression
- Lenguaje dominante
- C++
- Estrellas
- 18k
- Forks
- 2.3k
- Merge medio
- 5 d 7 h
- PR fusionados (30 d)
- 53
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pybind/pybind11
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 4 días
-
triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
pybind/pybind11#5604 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 4 días
-
docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
pybind/pybind11#747 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
array_t::at() returns a misaligned reference when the stride is not a multiple of alignof(T)Posiblemente ocupada @henryiii la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 4 días
Todos los issues de pybind/pybind11
Issues similares
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
tenstorrent/tt-umd#4084 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
ToffelsKater/X4_VR#34 ·
-
difficulty:easy prio:low refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NatronGitHub/openfx-supportext#220 ·
Los mantenedores suelen responder en 1 día