pybind/pybind11

[BUG]: Potential leaks when using enum_

Open

#3.865 aberto em 12 de abr. de 2022

Ver no GitHub
 (9 comments) (0 reactions) (0 assignees)C++ (2.005 forks)batch import
help wanted

Métricas do repositório

Stars
 (14.677 stars)
Métricas de merge de PR
 (Mesclagem média 5d 2h) (10 fundiu PRs em 30d)

Description

Required prerequisites

Problem description

Dear team, Asan reports possible memory leaks when wrapping enum from C++ (using py::enum_, precisely when a call to the value method is done.

Wrapping struct (using py::class_) seems to raise no leaks.

Config : python3.8 / gcc8.3, pybind v2.9.2

May be related to https://github.com/pybind/pybind11/issues/3228

Reproducible example code

#include <pybind11/pybind11.h>

enum Egg {
  Bar,
  Spam,  
};


namespace py = pybind11;

PYBIND11_MODULE(example, m) {
    py::enum_<Egg>(m, "Egg")
      .value("Bar", Egg::Bar)
      .value("Spam", Egg::Spam);
}

Guia do colaborador