Skip to content

Conversation

@shawgree
Copy link

@shawgree shawgree commented Oct 19, 2020

When running pydnp3 I found there was a double-delete on application exit. The root cause of this is the call to the destructor from Shutdown. When Python then cleans up the object the destructor is called again. However, removing the destructor call resulted in a hang. This issue is described in detail at the link below, my solution is borrowed from the comments there.

pybind/pybind11#1446

I did change the ownership of the DNP3Manager from a shared_ptr to a unique_ptr to simplify adding the custom deleter. Since the object is wholely owned by Python anyway, I believe this to be OK.

To reproduce this, run the master_cmd.py script, wait for the command prompt to appear then type 'quit'. Application will terminate with an error.

The ThreadPool owned by DNP3Manager causes a deadlock when it is destroyed without unlocking the GIL.
By returning the DNP3Manager with a custom deleter which unlocks the GIL during destruction the pool can be deleted.
Solution borrowed from: pybind/pybind11#1446
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

Successfully merging this pull request may close these issues.

2 participants