From b5d0e9eafce608ab12825b830a5d598c98db5319 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 5 May 2020 13:19:26 +0200 Subject: [PATCH] task: Fix memory leak when removing a task awaiting non-Panda future --- panda/src/event/pythonTask.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index 86200802a9..6264345348 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -779,6 +779,12 @@ void PythonTask:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); + // If we were polling something when we were removed, get rid of it. + if (_future_done != nullptr) { + Py_DECREF(_future_done); + _future_done = nullptr; + } + if (_upon_death != Py_None) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) // Use PyGILState to protect this asynchronous call.