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


On Fri, 2011-05-27 at 12:34 +0200, Bjoern Michaelsen wrote:
Hi Caolán,

On Fri, 27 May 2011 11:02:28 +0100
Caolán McNamara <caolanm@redhat.com> wrote:
 
So the original code doesn't do what it apparently thought it was
doing of using a double-check lock, but ends up using a unconditional
mutex lock every time, so it should be ok on all platforms/compilers,
no ?

If the stuff protected protected by the mutex has no side effects, yes.
If it has, the code would be executed twice -- although neatly
serialized by the mutex. Now gcc with bug 13684 fixed should never init
the static variable twice, so even if the ctor has side effects, it
would not hurt. And the pointer assignment is atomic and has no side
effects.

My thinking is that the case in gcc#13684 was a bare

static foo;

while in our 3-4 we have 

MutexGuard guard(Mutex::getGlobalMutex();
static foo;

The pointer assignment (in 3-4) is irrelevant really. In 3-4 it's all
just...

MutexGuard guard(...)
static ExceptionThrower s_thrower;
return &s_thrower;

so surely the compiler-generated (potentially thread-unsafe) equivalent
to

if (!thrower_initialized)
{
    call local static's s_thrower ctor
    thrower_initialized = true;
}

is protected by the MutexGuard, only one thread can enter and initialize
the local static, the other is blocked even before the check to see if
the local static is initialized, and only gets to have a look at that
when the other thread leaves, so its fine IMO.

Anyway, I think this is an aside, seeing as at the crash location we're
minutes/hours (given that I know that gets called even during startup)
past the time of initialization of that local object.

Most of these just point to high load -- of course exceptions are more
likely then.

We had a rash of crash-during-startup with the first call or two through
the uno bridge would blow up, which we could trace down to disk read
failures on the file-system of the mmaped home dir chunk of memory used
by the bridge. Would be awesome to even get a dmesg or /var/log/messages
dump of the minute before/after the time of the logged crash

C.


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.