[openoffice.org/f14/master] Resolves: rhbz#655686 get order of shutdown correct

Caolan McNamara caolanm at fedoraproject.org
Tue Apr 5 10:31:05 UTC 2011


commit e126713ee942bcedf296bb54aac02bf574542a3e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Apr 5 11:30:42 2011 +0100

    Resolves: rhbz#655686 get order of shutdown correct

 ...lated-rhbz-655686-get-order-of-shutdown-c.patch |  514 ++++++++++++++++++++
 openoffice.org.spec                                |    7 +-
 2 files changed, 520 insertions(+), 1 deletions(-)
---
diff --git a/0001-helgrind-Related-rhbz-655686-get-order-of-shutdown-c.patch b/0001-helgrind-Related-rhbz-655686-get-order-of-shutdown-c.patch
new file mode 100644
index 0000000..814a854
--- /dev/null
+++ b/0001-helgrind-Related-rhbz-655686-get-order-of-shutdown-c.patch
@@ -0,0 +1,514 @@
+From 47ea5b58c92777d8d35376b64a1c075fecb8b104 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Tue, 5 Apr 2011 11:19:35 +0100
+Subject: [PATCH] helgrind: Related: rhbz#655686 get order of shutdown correct
+
+---
+ sal/rtl/source/alloc_arena.c  |   44 +++-----------
+ sal/rtl/source/alloc_cache.c  |   44 +++-----------
+ sal/rtl/source/alloc_fini.cxx |   81 +++++++++++++++++++-------
+ sal/rtl/source/alloc_global.c |  131 +++++++++++++++++------------------------
+ sal/rtl/source/makefile.mk    |   15 +----
+ 5 files changed, 135 insertions(+), 180 deletions(-)
+
+diff --git a/sal/rtl/source/alloc_arena.c b/sal/rtl/source/alloc_arena.c
+index 27ac970..c2294d8 100644
+--- a/sal/rtl/source/alloc_arena.c
++++ b/sal/rtl/source/alloc_arena.c
+@@ -102,13 +102,6 @@ rtl_machdep_pagesize (void);
+ rtl_arena_type * gp_default_arena = 0;
+ 
+ 
+-/** rtl_arena_init()
+- *  @internal
+- */
+-static int
+-rtl_arena_init (void);
+-
+-
+ /* ================================================================= */
+ 
+ /** rtl_arena_segment_constructor()
+@@ -921,6 +914,8 @@ rtl_arena_deactivate (
+  *
+  * ================================================================= */
+ 
++extern void ensureArenaSingleton();
++
+ /** rtl_arena_create()
+  */
+ rtl_arena_type *
+@@ -973,7 +968,8 @@ try_alloc:
+     }
+     else if (gp_arena_arena == 0)
+     {
+-        if (rtl_arena_init())
++        ensureArenaSingleton();
++        if (gp_arena_arena)
+         {
+             /* try again */
+             goto try_alloc;
+@@ -1279,8 +1275,8 @@ rtl_machdep_pagesize (void)
+  *
+  * ================================================================= */
+ 
+-static void
+-rtl_arena_once_init (void)
++void
++rtl_arena_init (void)
+ {
+     {
+         /* list of arenas */
+@@ -1342,36 +1338,11 @@ rtl_arena_once_init (void)
+         );
+         OSL_ASSERT(gp_arena_arena != 0);
+     }
+-}
+-
+-static int
+-rtl_arena_init (void)
+-{
+-    static sal_once_type g_once = SAL_ONCE_INIT;
+-    SAL_ONCE(&g_once, rtl_arena_once_init);
+-    return (gp_arena_arena != 0);
++    OSL_TRACE("rtl_arena_init completed");
+ }
+ 
+ /* ================================================================= */
+ 
+-/*
+-  Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
+-
+-  Mac OS X does not seem to support "__cxa__atexit", thus leading
+-  to the situation that "__attribute__((destructor))__" functions
+-  (in particular "rtl_{memory|cache|arena}_fini") become called
+-  _before_ global C++ object d'tors.
+-
+-  Delegated the call to "rtl_arena_fini()" into a dummy C++ object,
+-  see alloc_fini.cxx .
+-*/
+-#if defined(__GNUC__) && !defined(MACOSX)
+-static void rtl_arena_fini (void) __attribute__((destructor));
+-#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+-#pragma fini(rtl_arena_fini)
+-static void rtl_arena_fini (void);
+-#endif /* __GNUC__ || __SUNPRO_C */
+-
+ void
+ rtl_arena_fini (void)
+ {
+@@ -1394,6 +1365,7 @@ rtl_arena_fini (void)
+         }
+         RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock));
+     }
++    OSL_TRACE("rtl_arena_fini completed");
+ }
+ 
+ /* ================================================================= */
+diff --git a/sal/rtl/source/alloc_cache.c b/sal/rtl/source/alloc_cache.c
+index 06de201..ebf799e 100644
+--- a/sal/rtl/source/alloc_cache.c
++++ b/sal/rtl/source/alloc_cache.c
+@@ -99,13 +99,6 @@ static rtl_cache_type * gp_cache_slab_cache = 0;
+ static rtl_cache_type * gp_cache_bufctl_cache = 0;
+ 
+ 
+-/** rtl_cache_init()
+- *  @internal
+- */
+-static int
+-rtl_cache_init (void);
+-
+-
+ /* ================================================================= */
+ 
+ /** RTL_CACHE_HASH_INDEX()
+@@ -1119,6 +1112,8 @@ rtl_cache_deactivate (
+  *
+  * ================================================================= */
+ 
++extern void ensureCacheSingleton();
++
+ /** rtl_cache_create()
+  */
+ rtl_cache_type *
+@@ -1176,7 +1171,8 @@ try_alloc:
+     }
+     else if (gp_cache_arena == 0)
+     {
+-        if (rtl_cache_init())
++        ensureCacheSingleton();
++        if (gp_cache_arena)
+         {
+             /* try again */
+             goto try_alloc;
+@@ -1583,8 +1579,8 @@ rtl_cache_wsupdate_all (void * arg)
+  *
+  * ================================================================= */
+ 
+-static void
+-rtl_cache_once_init (void)
++void
++rtl_cache_init (void)
+ {
+     {
+         /* list of caches */
+@@ -1680,36 +1676,11 @@ rtl_cache_once_init (void)
+     }
+ 
+     rtl_cache_wsupdate_init();
+-}
+-
+-static int
+-rtl_cache_init (void)
+-{
+-    static sal_once_type g_once = SAL_ONCE_INIT;
+-    SAL_ONCE(&g_once, rtl_cache_once_init);
+-    return (gp_cache_arena != 0);
++    OSL_TRACE("rtl_cache_init completed");
+ }
+ 
+ /* ================================================================= */
+ 
+-/*
+-  Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
+-
+-  Mac OS X does not seem to support "__cxa__atexit", thus leading
+-  to the situation that "__attribute__((destructor))__" functions
+-  (in particular "rtl_{memory|cache|arena}_fini") become called
+-  _before_ global C++ object d'tors.
+-
+-  Delegated the call to "rtl_cache_fini()" into a dummy C++ object,
+-  see alloc_fini.cxx .
+-*/
+-#if defined(__GNUC__) && !defined(MACOSX)
+-static void rtl_cache_fini (void) __attribute__((destructor));
+-#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+-#pragma fini(rtl_cache_fini)
+-static void rtl_cache_fini (void);
+-#endif /* __GNUC__ || __SUNPRO_C */
+-
+ void
+ rtl_cache_fini (void)
+ {
+@@ -1765,6 +1736,7 @@ rtl_cache_fini (void)
+         }
+         RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock));
+     }
++    OSL_TRACE("rtl_cache_fini completed");
+ }
+ 
+ /* ================================================================= */
+diff --git a/sal/rtl/source/alloc_fini.cxx b/sal/rtl/source/alloc_fini.cxx
+index 5bc174e..f079676 100644
+--- a/sal/rtl/source/alloc_fini.cxx
++++ b/sal/rtl/source/alloc_fini.cxx
+@@ -26,33 +26,72 @@
+  *
+  ************************************************************************/
+ 
+-/*
+-  Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
+-
+-  Mac OS X does not seem to support "__cxa__atexit", thus leading
+-  to the situation that "__attribute__((destructor))__" functions
+-  (in particular "rtl_{memory|cache|arena}_fini") become called
+-  _before_ global C++ object d'tors.
+-
+-  Using a C++ dummy object instead.
+-*/
++#include <rtl/instance.hxx>
+ 
+ extern "C" void rtl_memory_fini (void);
+-extern "C" void rtl_cache_fini (void);
+-extern "C" void rtl_arena_fini (void);
+-
+-struct RTL_Alloc_Fini
++extern "C" void rtl_memory_init (void);
++namespace
++{
++    struct rtlMemorySingleton
++    {
++        rtlMemorySingleton()
++        {
++            rtl_memory_init();
++        }
++        ~rtlMemorySingleton()
++        {
++            rtl_memory_fini();
++        }
++    };
++    class theMemorySingleton : public rtl::Static<rtlMemorySingleton, theMemorySingleton>{};
++}
++extern "C" void ensureMemorySingleton()
+ {
+-  ~RTL_Alloc_Fini() ;
+-};
++    theMemorySingleton::get();
++}
+ 
+-RTL_Alloc_Fini::~RTL_Alloc_Fini()
++extern "C" void rtl_cache_fini (void);
++extern "C" void rtl_cache_init (void);
++namespace
++{
++    struct rtlCacheSingleton
++    {
++        rtlCacheSingleton()
++        {
++            rtl_cache_init();
++        }
++        ~rtlCacheSingleton()
++        {
++            rtl_cache_fini();
++        }
++    };
++    class theCacheSingleton : public rtl::Static<rtlCacheSingleton, theCacheSingleton>{};
++}
++extern "C" void ensureCacheSingleton()
+ {
+-  rtl_memory_fini();
+-  rtl_cache_fini();
+-  rtl_arena_fini();
++    theCacheSingleton::get();
+ }
+ 
+-static RTL_Alloc_Fini g_RTL_Alloc_Fini;
++extern "C" void rtl_arena_fini (void);
++extern "C" void rtl_arena_init (void);
++namespace
++{
++    struct rtlArenaSingleton
++    {
++        rtlArenaSingleton()
++        {
++            rtl_arena_init();
++        }
++        ~rtlArenaSingleton()
++        {
++            rtl_arena_fini();
++        }
++    };
++    class theArenaSingleton : public rtl::Static<rtlArenaSingleton, theArenaSingleton>{};
++}
++extern "C" void ensureArenaSingleton()
++{
++    theArenaSingleton::get();
++}
+ 
+ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+diff --git a/sal/rtl/source/alloc_global.c b/sal/rtl/source/alloc_global.c
+index 70504ac..fb95e83 100644
+--- a/sal/rtl/source/alloc_global.c
++++ b/sal/rtl/source/alloc_global.c
+@@ -29,6 +29,7 @@
+ #include "alloc_impl.h"
+ #include "rtl/alloc.h"
+ #include <sal/macros.h>
++#include <osl/diagnose.h>
+ 
+ #include <string.h>
+ #include <stdio.h>
+@@ -66,7 +67,6 @@ static void determine_alloc_mode(void)
+ 
+ #include "internal/once.h"
+ #include "sal/macros.h"
+-#include "osl/diagnose.h"
+ 
+ /* ================================================================= *
+  *
+@@ -108,60 +108,7 @@ static rtl_cache_type * g_alloc_table[RTL_MEMORY_CACHED_LIMIT >> RTL_MEMALIGN_SH
+ 
+ static rtl_arena_type * gp_alloc_arena = 0;
+ 
+-/* ================================================================= *
+- *
+- * custom allocator initialization / finalization.
+- *
+- * ================================================================= */
+-
+-static void
+-rtl_memory_once_init (void)
+-{
+-    {
+-        /* global memory arena */
+-        OSL_ASSERT(gp_alloc_arena == 0);
+-
+-        gp_alloc_arena = rtl_arena_create (
+-            "rtl_alloc_arena",
+-            2048,     /* quantum */
+-            0,        /* w/o quantum caching */
+-            0,        /* default source */
+-            rtl_arena_alloc,
+-            rtl_arena_free,
+-            0         /* flags */
+-        );
+-        OSL_ASSERT(gp_alloc_arena != 0);
+-    }
+-    {
+-        sal_Size size;
+-        int i, n = RTL_MEMORY_CACHED_SIZES;
+-
+-        for (i = 0; i < n; i++)
+-        {
+-            char name[RTL_CACHE_NAME_LENGTH + 1];
+-            (void) snprintf (name, sizeof(name), "rtl_alloc_%lu", g_alloc_sizes[i]);
+-            g_alloc_caches[i] = rtl_cache_create (name, g_alloc_sizes[i], 0, NULL, NULL, NULL, NULL, NULL, 0);
+-        }
+-
+-        size = RTL_MEMALIGN;
+-        for (i = 0; i < n; i++)
+-        {
+-            while (size <= g_alloc_sizes[i])
+-            {
+-                g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT] = g_alloc_caches[i];
+-                size += RTL_MEMALIGN;
+-            }
+-        }
+-    }
+-}
+-
+-static int
+-rtl_memory_init (void)
+-{
+-    static sal_once_type g_once = SAL_ONCE_INIT;
+-    SAL_ONCE(&g_once, rtl_memory_once_init);
+-    return (gp_alloc_arena != 0);
+-}
++extern void ensureMemorySingleton();
+ 
+ /* ================================================================= *
+  *
+@@ -198,7 +145,8 @@ try_alloc:
+         }
+         else if (gp_alloc_arena == 0)
+         {
+-            if (rtl_memory_init())
++            ensureMemorySingleton();
++            if (gp_alloc_arena)
+             {
+                 /* try again */
+                 goto try_alloc;
+@@ -256,28 +204,58 @@ void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXT
+ 
+ #endif
+ 
++/* ================================================================= *
++ *
++ * custom allocator initialization / finalization.
++ *
++ * ================================================================= */
++
++void rtl_memory_init (void)
++{
++#if !defined(FORCE_SYSALLOC)
++    {
++        /* global memory arena */
++        OSL_ASSERT(gp_alloc_arena == 0);
++
++        gp_alloc_arena = rtl_arena_create (
++            "rtl_alloc_arena",
++            2048,     /* quantum */
++            0,        /* w/o quantum caching */
++            0,        /* default source */
++            rtl_arena_alloc,
++            rtl_arena_free,
++            0         /* flags */
++        );
++        OSL_ASSERT(gp_alloc_arena != 0);
++    }
++    {
++        sal_Size size;
++        int i, n = RTL_MEMORY_CACHED_SIZES;
++
++        for (i = 0; i < n; i++)
++        {
++            char name[RTL_CACHE_NAME_LENGTH + 1];
++            (void) snprintf (name, sizeof(name), "rtl_alloc_%lu", g_alloc_sizes[i]);
++            g_alloc_caches[i] = rtl_cache_create (name, g_alloc_sizes[i], 0, NULL, NULL, NULL, NULL, NULL, 0);
++        }
++
++        size = RTL_MEMALIGN;
++        for (i = 0; i < n; i++)
++        {
++            while (size <= g_alloc_sizes[i])
++            {
++                g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT] = g_alloc_caches[i];
++                size += RTL_MEMALIGN;
++            }
++        }
++    }
++#endif
++    OSL_TRACE("rtl_memory_init completed");
++}
++
+ /* ================================================================= */
+ 
+-/*
+-  Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
+-
+-  Mac OS X does not seem to support "__cxa__atexit", thus leading
+-  to the situation that "__attribute__((destructor))__" functions
+-  (in particular "rtl_memory_fini") become called _before_ global
+-  C++ object d'tors.
+-
+-  Delegated the call to "rtl_memory_fini" into a dummy C++ object,
+-  see memory_fini.cxx .
+-*/
+-#if defined(__GNUC__) && !defined(MACOSX) && !defined(AIX)
+-static void rtl_memory_fini (void) __attribute__((destructor));
+-#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+-#pragma fini(rtl_memory_fini)
+-static void rtl_memory_fini (void);
+-#endif /* __GNUC__ || __SUNPRO_C */
+-
+-void
+-rtl_memory_fini (void)
++void rtl_memory_fini (void)
+ {
+ #if !defined(FORCE_SYSALLOC)
+     int i, n;
+@@ -302,6 +280,7 @@ rtl_memory_fini (void)
+         gp_alloc_arena = 0;
+     }
+ #endif
++    OSL_TRACE("rtl_memory_fini completed");
+ }
+ 
+ /* ================================================================= *
+diff --git a/sal/rtl/source/makefile.mk b/sal/rtl/source/makefile.mk
+index 67ae7f8..9c3921d 100644
+--- a/sal/rtl/source/makefile.mk
++++ b/sal/rtl/source/makefile.mk
+@@ -100,12 +100,8 @@ SLOFILES=   \
+             $(SLO)$/math.obj        \
+             $(SLO)$/alloc_global.obj\
+             $(SLO)$/alloc_cache.obj \
+-            $(SLO)$/alloc_arena.obj
+-
+-.IF "$(OS)"=="MACOSX" || "$(OS)"=="AIX"
+-SLOFILES+=$(SLO)$/alloc_fini.obj
+-.ENDIF
+-
++            $(SLO)$/alloc_arena.obj \
++            $(SLO)$/alloc_fini.obj
+ 
+ OBJFILES=   \
+             $(OBJ)$/memory.obj      \
+@@ -132,11 +128,8 @@ OBJFILES=   \
+             $(OBJ)$/math.obj \
+             $(OBJ)$/alloc_global.obj\
+             $(OBJ)$/alloc_cache.obj \
+-            $(OBJ)$/alloc_arena.obj
+-
+-.IF "$(OS)"=="MACOSX" || "$(OS)"=="AIX"
+-OBJFILES+=$(OBJ)$/alloc_fini.obj
+-.ENDIF
++            $(OBJ)$/alloc_arena.obj \
++            $(OBJ)$/alloc_fini.obj
+ 
+ 
+ APP1TARGET=gen_makefile
+-- 
+1.7.4.1
+
diff --git a/openoffice.org.spec b/openoffice.org.spec
index f005a3e..0fb9643 100644
--- a/openoffice.org.spec
+++ b/openoffice.org.spec
@@ -1,6 +1,6 @@
 %define oootag OOO330
 %define ooomilestone 20
-%define rh_rpm_release 4
+%define rh_rpm_release 5
 
 # rhbz#465664 jar-repacking breaks help by reordering META-INF/MANIFEST.MF
 %define __jar_repack %{nil}
@@ -170,6 +170,7 @@ Patch86: 0001-Resolves-rhbz-672818-bandaid-for-crash-in-SwTxtNode-.patch
 Patch87: 0001-Related-rhbz-684477-make-sure-this-is-thread-safe.patch
 Patch88: 0001-Resolves-rhbz-684620-crash-with-NULL-pTableBox.patch
 Patch89: libreoffice-fdo33947.sd.print.crash.patch
+Patch90: 0001-helgrind-Related-rhbz-655686-get-order-of-shutdown-c.patch
 
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 %define instdir %{_libdir}
@@ -1756,6 +1757,7 @@ cp -p %{SOURCE5} external/unowinreg/unowinreg.dll
 %patch87 -p1 -b .rhbz684477-make-sure-this-is-thread-safe.patch
 %patch88 -p1 -b .rhbz684620-crash-with-NULL-pTableBox.patch
 %patch89 -p1 -b .fdo33947.sd.print.crash.patch
+%patch90 -p1 -b .rhbz655686-get-order-of-shutdown-c.patch
 touch scripting/source/pyprov/delzip
 touch scripting/util/provider/beanshell/delzip
 touch scripting/util/provider/javascript/delzip
@@ -3951,6 +3953,9 @@ unopkg remove --shared org.openoffice.legacy.ScriptProviderForPython.zip > /dev/
 %endif
 
 %changelog
+* Tue Apr 05 2011 Caolán McNamara <caolanm at redhat.com>- 1:3.3.0-20.5-UNBUILT
+- Resolves: rhbz#655686 get order of shutdown correct
+
 * Mon Apr 04 2011 Caolán McNamara <caolanm at redhat.com>- 1:3.3.0-20.4
 - Related: rhz#691802 backport sd print crash fix
 


More information about the scm-commits mailing list