It's a dangling pointer that for no reason should show up rarely, and
for no reason should show up only on ia64, but it does.

Anyway the attached patch, which I'll commit upstream after some more
testing, fixes it.  The idea is that a nomemory hook is now able to
divert the allocation to another memory arena.

Here is a more reduced testcase for fun:

ObjectMemory compact.
173 timesRepeat: [ String new: 4450 ].
ObjectMemory compact

Paolo
diff --git a/libgst/alloc.c b/libgst/alloc.c
index 47c20b8..8c44efe 100644
--- a/libgst/alloc.c
+++ b/libgst/alloc.c
@@ -261,8 +261,11 @@ nospace:
       if (h->heap_limit && h->heap_total <= h->heap_limit
          && h->heap_total + nsz > h->heap_limit && h->nomemory)
        {
-         h->nomemory (h, nsz);
-         break;
+         h = h->nomemory (h, nsz);
+         if (h)
+           break;
+         else
+           return NULL;
        }
 
     case 2:
diff --git a/libgst/alloc.h b/libgst/alloc.h
index 61c2825..fa9e592 100644
--- a/libgst/alloc.h
+++ b/libgst/alloc.h
@@ -97,7 +97,7 @@ heap_block;
 typedef struct heap_data heap_data;
 
 typedef void (*allocating_hook_t) (heap_data *, heap_block *, size_t);
-typedef void (*nomemory_hook_t) (heap_data *, size_t);
+typedef heap_data *(*nomemory_hook_t) (heap_data *, size_t);
 
 struct heap_data
 {
diff --git a/libgst/oop.c b/libgst/oop.c
index 4568277..6df0343 100644
--- a/libgst/oop.c
+++ b/libgst/oop.c
@@ -210,7 +210,7 @@ static int oldspace_sigsegv_handler (void* fault_address, 
int serious);
 #endif
 
 /* Hook that triggers garbage collection.  */
-static void oldspace_nomemory (heap_data *h, size_t sz);
+static heap_data *oldspace_nomemory (heap_data *h, size_t sz);
 
 /* Answer the number of fields to be scanned in the object starting
    at OBJ, with the given FLAGS on its OOP.  */
@@ -891,11 +891,16 @@ oldspace_before_freeing (heap_data *h, heap_block *blk, 
size_t sz)
   _gst_mem_protect ((PTR) blk, sz, PROT_READ | PROT_WRITE);
 }
 
-void
+heap_data *
 oldspace_nomemory (heap_data *h, size_t sz)
 {
   if (!_gst_gc_running)
-    _gst_global_gc (sz);
+    {
+      _gst_global_gc (sz);
+      return _gst_mem.old;
+    }
+  else
+    return NULL;
 }
 
 #ifndef NO_SIGSEGV_HANDLING

Reply via email to