[rtems commit] heap: Workaround for workspace protection

Sebastian Huber sebh at rtems.org
Tue Jun 25 15:01:50 UTC 2013


Module:    rtems
Branch:    master
Commit:    1d48e25d6ba51e92773e28c5d561557491fc7a9d
Changeset: http://git.rtems.org/rtems/commit/?id=1d48e25d6ba51e92773e28c5d561557491fc7a9d

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jun 24 16:48:17 2013 +0200

heap: Workaround for workspace protection

---

 cpukit/score/src/heapfree.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/cpukit/score/src/heapfree.c b/cpukit/score/src/heapfree.c
index 30a84a0..7ff1363 100644
--- a/cpukit/score/src/heapfree.c
+++ b/cpukit/score/src/heapfree.c
@@ -81,6 +81,7 @@
   )
   {
     bool do_free = true;
+    Heap_Block *const next = block->Protection_begin.next_delayed_free_block;
 
     /*
      * Sometimes after a free the allocated area is still in use.  An example
@@ -88,7 +89,6 @@
      * disable level is a way to detect this use case.
      */
     if ( _Thread_Dispatch_is_enabled() ) {
-      Heap_Block *const next = block->Protection_begin.next_delayed_free_block;
       if ( next == NULL ) {
         _Heap_Protection_delay_block_free( heap, block );
         do_free = false;
@@ -97,6 +97,12 @@
       } else {
         _Heap_Protection_block_error( heap, block );
       }
+    } else if ( next == NULL ) {
+      /*
+       * This is a hack to prevent heavy workspace fragmentation which would
+       * lead to test suite failures.
+       */
+      _Heap_Protection_free_all_delayed_blocks( heap );
     }
 
     return do_free;




More information about the vc mailing list