[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
kbalazs at webkit.org
kbalazs at webkit.org
Wed Dec 22 15:30:51 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 792577a5e9e863f529a57e0212fc3b6906642ed6
Author: kbalazs at webkit.org <kbalazs at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Nov 5 12:03:50 2010 +0000
[Qt][WK2] Left over files and shared memory segments
https://bugs.webkit.org/show_bug.cgi?id=48985
Reviewed by Andreas Kling.
* Platform/qt/SharedMemoryQt.cpp:
(WebKit::SharedMemory::create): Force deletion of the QSharedMemory
object on terminate by connecting QCoreApplication::aboutToQuit with
deleteLater. Add the object to the CrashHandler as well to release the
shared memory segment even on crash.
(WebKit::SharedMemory::~SharedMemory):
* Shared/qt/CrashHandler.cpp: Added.
CrashHandler has a container for QObjects that we want to
destroy on crash. When we got a signal that we interpret as
a crash then it destroys those objects.
(WebKit::CrashHandler::CrashHandler):
(WebKit::CrashHandler::signalHandler):
(WebKit::CrashHandler::deleteObjects):
* Shared/qt/CrashHandler.h: Added.
(WebKit::CrashHandler::instance):
(WebKit::CrashHandler::didDelete):
(WebKit::CrashHandler::markForDeletionOnCrash):
* UIProcess/Launcher/qt/ProcessLauncherQt.cpp:
(WebKit::ProcessLauncherHelper::ProcessLauncherHelper):
Add the object itself to the CrashHandler to close the QLocalServer
even on crash. Without that the QLocalServer leaves over socket files on the disk.
(WebKit::ProcessLauncherHelper::~ProcessLauncherHelper):
* WebKit2.pro:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71409 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 72a1674..2ded1fb 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,34 @@
+2010-11-05 Balazs Kelemen <kbalazs at webkit.org>
+
+ Reviewed by Andreas Kling.
+
+ [Qt][WK2] Left over files and shared memory segments
+ https://bugs.webkit.org/show_bug.cgi?id=48985
+
+ * Platform/qt/SharedMemoryQt.cpp:
+ (WebKit::SharedMemory::create): Force deletion of the QSharedMemory
+ object on terminate by connecting QCoreApplication::aboutToQuit with
+ deleteLater. Add the object to the CrashHandler as well to release the
+ shared memory segment even on crash.
+ (WebKit::SharedMemory::~SharedMemory):
+ * Shared/qt/CrashHandler.cpp: Added.
+ CrashHandler has a container for QObjects that we want to
+ destroy on crash. When we got a signal that we interpret as
+ a crash then it destroys those objects.
+ (WebKit::CrashHandler::CrashHandler):
+ (WebKit::CrashHandler::signalHandler):
+ (WebKit::CrashHandler::deleteObjects):
+ * Shared/qt/CrashHandler.h: Added.
+ (WebKit::CrashHandler::instance):
+ (WebKit::CrashHandler::didDelete):
+ (WebKit::CrashHandler::markForDeletionOnCrash):
+ * UIProcess/Launcher/qt/ProcessLauncherQt.cpp:
+ (WebKit::ProcessLauncherHelper::ProcessLauncherHelper):
+ Add the object itself to the CrashHandler to close the QLocalServer
+ even on crash. Without that the QLocalServer leaves over socket files on the disk.
+ (WebKit::ProcessLauncherHelper::~ProcessLauncherHelper):
+ * WebKit2.pro:
+
2010-11-04 Jia Pu <jpu at apple.com>
Reviewed by Dan Bernstein.
diff --git a/WebKit2/Platform/qt/SharedMemoryQt.cpp b/WebKit2/Platform/qt/SharedMemoryQt.cpp
index 0c237b0..13ea4be 100644
--- a/WebKit2/Platform/qt/SharedMemoryQt.cpp
+++ b/WebKit2/Platform/qt/SharedMemoryQt.cpp
@@ -29,8 +29,10 @@
#include "ArgumentDecoder.h"
#include "ArgumentEncoder.h"
+#include "CrashHandler.h"
#include "WebCoreArgumentCoders.h"
#include <unistd.h>
+#include <QCoreApplication>
#include <QLatin1String>
#include <QSharedMemory>
#include <QString>
@@ -92,10 +94,16 @@ PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
QSharedMemory* impl = new QSharedMemory(createUniqueKey());
bool created = impl->create(size);
ASSERT_UNUSED(created, created);
+
sharedMemory->m_impl = impl;
sharedMemory->m_size = size;
sharedMemory->m_data = impl->data();
+ impl->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater()));
+
+ // Release the shared memory segment even on crash!
+ CrashHandler::instance()->markForDeletionOnCrash(impl);
+
return sharedMemory.release();
}
@@ -121,11 +129,17 @@ PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection p
QSharedMemory* impl = new QSharedMemory(QString(handle.m_key));
bool attached = impl->attach(accessMode(protection));
ASSERT_UNUSED(attached, attached);
+
sharedMemory->m_impl = impl;
ASSERT(handle.m_size == impl->size());
sharedMemory->m_size = handle.m_size;
sharedMemory->m_data = impl->data();
+ impl->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater()));
+
+ // Release the shared memory segment even on crash!
+ CrashHandler::instance()->markForDeletionOnCrash(impl);
+
return sharedMemory.release();
}
@@ -134,6 +148,7 @@ SharedMemory::~SharedMemory()
// m_impl must be non-null and it must point to a valid QSharedMemory object.
ASSERT(qobject_cast<QSharedMemory*>(m_impl));
delete m_impl;
+ CrashHandler::instance()->didDelete(m_impl);
}
bool SharedMemory::createHandle(Handle& handle, Protection protection)
diff --git a/WebKit2/Shared/qt/CrashHandler.cpp b/WebKit2/Shared/qt/CrashHandler.cpp
new file mode 100644
index 0000000..78ac713
--- /dev/null
+++ b/WebKit2/Shared/qt/CrashHandler.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 University of Szeged. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "CrashHandler.h"
+
+#include <csignal>
+#include <cstdlib>
+#include <wtf/AlwaysInline.h>
+
+namespace WebKit {
+
+CrashHandler* CrashHandler::theInstance = 0;
+
+CrashHandler::CrashHandler()
+ : m_inDeleteObjects(false)
+{
+ signal(SIGABRT, &CrashHandler::signalHandler);
+ signal(SIGBUS, &CrashHandler::signalHandler);
+ signal(SIGILL, &CrashHandler::signalHandler);
+ signal(SIGINT, &CrashHandler::signalHandler);
+ signal(SIGFPE, &CrashHandler::signalHandler);
+ signal(SIGQUIT, &CrashHandler::signalHandler);
+ signal(SIGSEGV, &CrashHandler::signalHandler);
+ signal(SIGTRAP, &CrashHandler::signalHandler);
+}
+
+NO_RETURN void CrashHandler::signalHandler(int)
+{
+ CrashHandler::theInstance->deleteObjects();
+ exit(EXIT_FAILURE);
+}
+
+void CrashHandler::deleteObjects()
+{
+ m_inDeleteObjects = true;
+ qDeleteAll(m_objects);
+}
+
+} // namespace WebKit
diff --git a/WebKit2/Shared/qt/CrashHandler.h b/WebKit2/Shared/qt/CrashHandler.h
new file mode 100644
index 0000000..672f95c
--- /dev/null
+++ b/WebKit2/Shared/qt/CrashHandler.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 University of Szeged. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CrashHandler_h
+#define CrashHandler_h
+
+#include <QList>
+#include <QObject>
+#include <wtf/HashSet.h>
+#include <wtf/StdLibExtras.h>
+
+namespace WebKit {
+
+class CrashHandler : private QObject {
+ Q_OBJECT
+public:
+ static CrashHandler* instance()
+ {
+ if (!theInstance)
+ theInstance = new CrashHandler();
+ return theInstance;
+ }
+
+ void markForDeletionOnCrash(QObject* object)
+ {
+ theInstance->m_objects.append(object);
+ }
+
+ void didDelete(QObject* object)
+ {
+ if (m_inDeleteObjects)
+ return;
+ theInstance->m_objects.removeOne(object);
+ }
+
+private:
+ static void signalHandler(int);
+ static CrashHandler* theInstance;
+
+ CrashHandler();
+
+ void deleteObjects();
+
+ QList<QObject*> m_objects;
+ bool m_inDeleteObjects;
+};
+
+} // namespace WebKit
+
+#endif // CrashHandler_h
diff --git a/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
index 647c581..8f67b4f 100644
--- a/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
+++ b/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
@@ -29,6 +29,7 @@
#include "Connection.h"
#include "NotImplemented.h"
#include "RunLoop.h"
+#include "CrashHandler.h"
#include "WebProcess.h"
#include <runtime/InitializeThreading.h>
#include <string>
@@ -102,6 +103,7 @@ QLocalSocket* ProcessLauncherHelper::takePendingConnection()
ProcessLauncherHelper::~ProcessLauncherHelper()
{
m_server.close();
+ CrashHandler::instance()->didDelete(this);
}
ProcessLauncherHelper::ProcessLauncherHelper()
@@ -113,6 +115,9 @@ ProcessLauncherHelper::ProcessLauncherHelper()
}
connect(&m_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater()), Qt::QueuedConnection);
+
+ // Do not leave socket files on the disk even on crash!
+ CrashHandler::instance()->markForDeletionOnCrash(this);
}
ProcessLauncherHelper* ProcessLauncherHelper::instance()
diff --git a/WebKit2/WebKit2.pro b/WebKit2/WebKit2.pro
index a13256b..4d40cd7 100644
--- a/WebKit2/WebKit2.pro
+++ b/WebKit2/WebKit2.pro
@@ -213,6 +213,7 @@ HEADERS += \
Shared/NativeWebKeyboardEvent.h \
Shared/NotImplemented.h \
Shared/StringPairVector.h \
+ Shared/qt/CrashHandler.h \
Shared/qt/PlatformCertificateInfo.h \
Shared/qt/UpdateChunk.h \
Shared/qt/WebEventFactoryQt.h \
@@ -379,6 +380,7 @@ SOURCES += \
Shared/MutableArray.cpp \
Shared/MutableDictionary.cpp \
Shared/qt/BackingStoreQt.cpp \
+ Shared/qt/CrashHandler.cpp \
Shared/qt/NativeWebKeyboardEventQt.cpp \
Shared/qt/UpdateChunk.cpp \
Shared/qt/WebCoreArgumentCodersQt.cpp \
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list