Commit cca20a7f authored by Jason Rhinelander's avatar Jason Rhinelander
Browse files

Fix occassional segfault introduced by #960

The fix for #960 could result a type being registered multiple times if
its `__init__` is called multiple times.  This can happen perfectly
ordinarily when python-side multiple inheritance is involved: for
example, with a diamond inheritance pattern with each intermediate
classes invoking the parent constructor.

With the change in #960, the multiple `__init__` calls meant
`register_instance` was called multiple times, but the deletion only
deleted it once.  Thus, if a future instance of the same type was
allocated at the same location, pybind would pick it up as a registered
type.

This fixes the issue by tracking whether a value pointer has been
registered to avoid both double-registering it.  (There's also a slight
optimization of not needing to do a registered_instances lookup when the
type is known not registered, but this is secondary).
parent 85d63c3b
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment