[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH]: Solaris artsd crashes
From: Stefan Westerfeld <stefan () space ! twc ! de>
Date: 2002-03-20 20:15:33
[Download RAW message or body]
This is a MIME-formatted message. If you see this text it means that your
E-mail software does not support MIME-formatted messages.
Hi!
Some people have reported artsd crashing on Solaris. A possible cause could
be that we're using long long, and the gsl allocator might return non-8-byte-
boundary aligned memory. Here is a patch that tries to solve the issue. It
would be great if somebody using Solaris could test this and see if it fixed
the artsd crashes.
Cu... Stefan
--
-* Stefan Westerfeld, stefan@space.twc.de (PGP!), Hamburg/Germany
KDE Developer, project infos at http://space.twc.de/~stefan/kde *-
["20020320-arts-gsl-alignment.diff" (text/plain)]
Index: gslcommon.c
===================================================================
RCS file: /cvs/gnome/beast/bse/gslcommon.c,v
retrieving revision 1.11
diff -u -r1.11 gslcommon.c
--- gslcommon.c 11 Feb 2002 21:49:22 -0000 1.11
+++ gslcommon.c 20 Mar 2002 20:02:45 -0000
@@ -39,8 +39,10 @@
#endif
-#define SIMPLE_CACHE_SIZE (1024)
#define PREALLOC (8)
+#define SIMPLE_CACHE_SIZE (64)
+#define TS8_SIZE (MAX (sizeof (GTrashStack), 8))
+#define DBG8_SIZE (MAX (sizeof (gsize), 8))
/* --- variables --- */
@@ -50,7 +52,7 @@
/* --- memory allocation --- */
static GslMutex global_memory = { 0, };
-static GTrashStack *simple_cache[SIMPLE_CACHE_SIZE] = { NULL, };
+static GTrashStack *simple_cache[SIMPLE_CACHE_SIZE] = { 0, 0, 0, /* ... */ };
static gulong memory_allocated = 0;
const guint
@@ -64,10 +66,14 @@
{
gpointer mem;
- if (mem_size >= sizeof (GTrashStack) && mem_size < SIMPLE_CACHE_SIZE + sizeof (GTrashStack))
+ if (mem_size >= TS8_SIZE && mem_size / 8 < SIMPLE_CACHE_SIZE)
{
+ guint cell;
+
+ mem_size = (mem_size + 7) & ~0x7;
+ cell = (mem_size >> 3) - 1;
GSL_SPIN_LOCK (&global_memory);
- mem = g_trash_stack_pop (simple_cache + mem_size - sizeof (GTrashStack));
+ mem = g_trash_stack_pop (simple_cache + cell);
GSL_SPIN_UNLOCK (&global_memory);
if (!mem)
{
@@ -78,7 +84,7 @@
memory_allocated += mem_size * PREALLOC;
for (i = 0; i < PREALLOC - 1; i++)
{
- g_trash_stack_push (simple_cache + mem_size - sizeof (GTrashStack), cache_mem);
+ g_trash_stack_push (simple_cache + cell, cache_mem);
cache_mem += mem_size;
}
GSL_SPIN_UNLOCK (&global_memory);
@@ -99,10 +105,14 @@
low_free (gsize mem_size,
gpointer mem)
{
- if (mem_size >= sizeof (GTrashStack) && mem_size < SIMPLE_CACHE_SIZE + sizeof (GTrashStack))
+ if (mem_size >= TS8_SIZE && mem_size / 8 < SIMPLE_CACHE_SIZE)
{
+ guint cell;
+
+ mem_size = (mem_size + 7) & ~0x7;
+ cell = (mem_size >> 3) - 1;
GSL_SPIN_LOCK (&global_memory);
- g_trash_stack_push (simple_cache + mem_size - sizeof (GTrashStack), mem);
+ g_trash_stack_push (simple_cache + cell, mem);
GSL_SPIN_UNLOCK (&global_memory);
}
else
@@ -117,17 +127,17 @@
gpointer
gsl_alloc_memblock (gsize block_size)
{
- gpointer mem;
+ guint8 *cmem;
gsize *debug_size;
g_return_val_if_fail (block_size >= sizeof (gpointer), NULL); /* cache-link size */
- mem = low_alloc (block_size + sizeof (*debug_size));
- debug_size = mem;
+ cmem = low_alloc (block_size + DBG8_SIZE);
+ debug_size = (gsize*) cmem;
*debug_size = block_size;
- mem = debug_size + 1;
-
- return mem;
+ cmem += DBG8_SIZE;
+
+ return cmem;
}
void
@@ -135,15 +145,16 @@
gpointer mem)
{
gsize *debug_size;
-
+ guint8 *cmem;
+
g_return_if_fail (mem != NULL);
- debug_size = mem;
- debug_size -= 1;
- mem = debug_size;
+ cmem = mem;
+ cmem -= DBG8_SIZE;
+ debug_size = (gsize*) cmem;
g_return_if_fail (block_size == *debug_size);
- low_free (block_size + sizeof (*debug_size), mem);
+ low_free (block_size + DBG8_SIZE, cmem);
}
void
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic