Ticket #9421: 0001-Change-to-using-QPointer-so-double-delete-issues-sto.patch

File 0001-Change-to-using-QPointer-so-double-delete-issues-sto.patch, 2.4 KB (added by beirdo, 9 years ago)
  • mythtv/libs/libmythbase/system-unix.cpp

    From 4e915e0b5e1883762f1a59b7df486056b4e7bf10 Mon Sep 17 00:00:00 2001
    From: Gavin Hurlbut <ghurlbut@mythtv.org>
    Date: Thu, 3 Feb 2011 22:22:04 -0800
    Subject: [PATCH] Change to using QPointer so double delete issues stop
    
    We keep on seem to get some race conditions with myth_system launched things
    exiting too fast (i.e. command not found, fast crashes) and causing a set of
    race conditions involving deleting the MythSystemUnix item when the process
    ends.  The use of QPointer should avoid these problems as when a QPointer item
    is deleted, the reference is automatically zeroed, even if it was deleted
    elsewhere (or so the docs seem to say).  With that plus a few more null checks
    and we can avoid using it after it's freed.
    ---
     mythtv/libs/libmythbase/system-unix.cpp |    6 ++++++
     mythtv/libs/libmythbase/system-unix.h   |    5 +++--
     2 files changed, 9 insertions(+), 2 deletions(-)
    
    diff --git a/mythtv/libs/libmythbase/system-unix.cpp b/mythtv/libs/libmythbase/system-unix.cpp
    index 2c43a4c..9b64d08 100644
    a b void MythSystemManager::run(void) 
    335335            next = i + 1;
    336336            pid  = i.key();
    337337            ms   = i.value();
     338            if (!ms)
     339                continue;
    338340
    339341            // handle processes beyond marked timeout
    340342            if( ms->m_timeout > 0 && ms->m_timeout < now )
    void MythSystemSignalManager::run(void) 
    443445            MythSystemUnix *ms = msList.takeFirst();
    444446            listLock.unlock();
    445447
     448            // This can happen if it has been deleted already
     449            if (!ms)
     450                continue;
     451
    446452            ms->m_parent->HandlePostRun();
    447453
    448454            if (ms->m_stdpipe[0] > 0)
  • mythtv/libs/libmythbase/system-unix.h

    diff --git a/mythtv/libs/libmythbase/system-unix.h b/mythtv/libs/libmythbase/system-unix.h
    index 0785559..7279811 100644
    a b  
    1010#include <QThread>
    1111#include <QWaitCondition>
    1212#include <QMutex>
     13#include <QPointer>
    1314#include <sys/select.h>
    1415#include "mythsystem.h"
    1516
    1617class MythSystemUnix;
    1718
    18 typedef QMap<pid_t, MythSystemUnix *> MSMap_t;
     19typedef QMap<pid_t, QPointer<MythSystemUnix> > MSMap_t;
    1920typedef QMap<int, QBuffer *> PMap_t;
    20 typedef QList<MythSystemUnix *> MSList_t;
     21typedef QList<QPointer<MythSystemUnix> > MSList_t;
    2122
    2223class MythSystemIOHandler: public QThread
    2324{