diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-08-23 16:07:50 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-09-21 12:02:49 +0200 |
commit | 06ce312f79cb0871c0b110ba4bff16f5aaa0f538 (patch) | |
tree | c50424e53902a565d700321740f5898b9d6f004b /include/vcl/task.hxx | |
parent | 1cfcbf3573206c2e9c435f276ba8d7431c75665c (diff) |
Workaround static Task destruction error
A task has to get the SchedulerLock to remove itself from the
Scheduler list. This doesn't work, if the Task is static, as the
static Scheduler might be destroyed earlier. In this case we fail
with the following backtrace:
#0 SchedulerMutex::acquire
#1 Task::~Task
#2 __run_exit_handlers
Thanks to Michael Stahl to catching this backtrace.
As a workaround this marks static tasks, so they ignore the
SchedulerMutex in the destructor, We also mark all scheduled Tasks
as "static" in DeInitScheduler, as their cleanup was already done.
In the end all Tasks should be removed from static objects.
Change-Id: I38be3206378b9449193efaccbc96896ac8de9478
Reviewed-on: https://gerrit.libreoffice.org/42574
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'include/vcl/task.hxx')
-rw-r--r-- | include/vcl/task.hxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/vcl/task.hxx b/include/vcl/task.hxx index e45fe3f5ae73..2711d4343932 100644 --- a/include/vcl/task.hxx +++ b/include/vcl/task.hxx @@ -47,6 +47,7 @@ class VCL_DLLPUBLIC Task const sal_Char *mpDebugName; ///< Useful for debugging TaskPriority mePriority; ///< Task priority bool mbActive; ///< Currently in the scheduler + bool mbStatic; ///< Is a static object protected: static void StartTimer( sal_uInt64 nMS ); @@ -88,6 +89,15 @@ public: void Stop(); bool IsActive() const { return mbActive; } + + /** + * This function must be called for static tasks, so the Task destructor + * ignores the SchedulerMutex, as it may not be available anymore. + * The cleanup is still correct, as it has already happened in + * DeInitScheduler call well before the static destructor calls. + */ + void SetStatic() { mbStatic = true; } + bool IsStatic() const { return mbStatic; } }; #endif // INCLUDED_VCL_TASK_HXX |