Skip to content

virtual methods: garbage collected trampolines may corrupt future trampoline classes? #1923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
EricCousineau-TRI opened this issue Sep 12, 2019 · 0 comments

Comments

@EricCousineau-TRI
Copy link
Collaborator

EricCousineau-TRI commented Sep 12, 2019

Issue description

When trying to investigate #1922, I accidentally reproduced the wrong thing, but ended up finding another bug. I haven't root-caused this, but this is the general breakdown:

  • Define a base class + trampoline and bind those in C++, and then make derived class in Python which inherits from it.
  • You should be able to instantiate both of them (if they are default-constructible)
  • Delete those classes and garbage collect (and double-check to ensure they've been deleted)
  • Define another base class + trampoline in C++, and then a derived class in Python
  • Try constructing the new derived class; you may end up getting TypeError: __init__(self, ...) called with invalid `self` argument.

Reproducible example code

EricCousineau-TRI@c11472d

I'm running this on Ubuntu 18.04, using Python 3.6.8.

My generic guess is that this is due to the use of hashing type.ptr(), which cause a hash collision when an object's memory location is reused after it's deleted (similar to #1922).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant