Greetings friends!

Today I finally found the time and bravery to have another stab at the
ugly thread leak that Padre aquired along with the Task 2.0 rewrite.

After adding extensive additional detail to the tracing around message
passing, I believe I managed to isolate the problem to instances when
a 'cancel' message (to tell a running task to abort early) arrives
after the thread it is being sent to has completed it's ->run phase
and sent it's ->stopped message.

The stub ->cancel method on Padre::TaskWorker which was designed to
catch these stray messages and ignore them failed to return true. The
TaskWorker main loop uses a true response to task method calls to
indicate that it should continue processing messages (allowing certain
tasks that do potentially destructive or resource wasting things to
signal that the thread should be terminated and a new worker created
rather than recycle the worker). This feature is not in use yet, and
so the parent thread expects all children to run forever, except
during shutdown.

Unfortunately, this thread shutdown occurs without any kind of signal
to the parent that the thread is stopping, and so the parent believed
the worker was still active. This resulting in the next task after the
cancelled one being sent to the worker, but never arriving (which
became a red herring during previous fix attempts, as it appeared that
THAT task had stalled, and that was somehow to do with the bug).

The fix for the leak is embarrasingly simple, with the following line
of code added to the end of Padre::TaskWorker::cancel...

  return 1;

With this change, I believe the bug to be fixed.

The "restart hung task manager" feature continues, however, to destroy
the task manager state if the task manager becomes legitimately
stressed.

Rather than remove it, I have set the default for the restart hung
task manager feature to false instead of true.

Anyone with the feature set manually to true should revert to the default.

Further, anyone interesting in task heavy things should see if they
can overload of break the task manager now the bug is believed to be
gone.

Thanks, and apologies for the long delay in fixing this.

Adam K
_______________________________________________
Padre-dev mailing list
Padre-dev@perlide.org
http://mail.perlide.org/mailman/listinfo/padre-dev

Reply via email to