Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


hi Stephan,

On 23/02/12 10:48, Stephan Bergmann wrote:

+void salhelper::Thread::launch() {
+    SAL_INFO("salhelper.thread", "launch " << name_);
+    // Assumption is that osl::Thread::create returns normally iff it causes
+    // osl::Thread::run to start executing:

looks like this assumption which you moved there is actually wrong

+    acquire();
+    try {
+        create();
+    } catch (...) {
+        release();
+        throw;
+    }


    sal_Bool SAL_CALL create()
    {
        assert(m_hThread == 0); // only one running thread per instance
           if (m_hThread)
            return sal_False;

        m_hThread = osl_createSuspendedThread( threadFunc, (void*)this);
        if ( m_hThread )
            osl_resumeThread(m_hThread);

        return m_hThread != 0;
    }

doesn't look like anything throws here, given those are C functions...

how about the attached patch?
From cf22e569d485d050a535b3e598d7e255aed98597 Mon Sep 17 00:00:00 2001
From: Michael Stahl <mstahl@redhat.com>
Date: Thu, 23 Feb 2012 14:53:56 +0100
Subject: [PATCH] salhelper::Thread::launch: check create() failure

The assumption in the comment is clearly wrong, as osl::Thread::create
returns a boolean result to indicate failure.
---
 salhelper/source/thread.cxx |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/salhelper/source/thread.cxx b/salhelper/source/thread.cxx
index bf7c1f1..d1644be 100644
--- a/salhelper/source/thread.cxx
+++ b/salhelper/source/thread.cxx
@@ -32,15 +32,20 @@
 #include "sal/log.hxx"
 #include "salhelper/thread.hxx"
 
+#include <stdexcept>
+
+
 salhelper::Thread::Thread(char const * name): name_(name) {}
 
 void salhelper::Thread::launch() {
     SAL_INFO("salhelper.thread", "launch " << name_);
-    // Assumption is that osl::Thread::create returns normally iff it causes
-    // osl::Thread::run to start executing:
     acquire();
     try {
-        create();
+        bool const bSuccess = create();
+        if (!bSuccess) {
+            // cannot throw css::uno::RuntimeException (udkapi not available)
+            throw ::std::runtime_error("osl::Thread::create() failed");
+        }
     } catch (...) {
         release();
         throw;
-- 
1.7.7.6


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.