Index: cpukit/include/rtems/score/heap.h
===================================================================
--- cpukit/include/rtems/score/heap.h	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ cpukit/include/rtems/score/heap.h	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -135,4 +135,60 @@
 typedef struct Heap_Block Heap_Block;
 
+/**
+ * @brief The heap error reason.
+ *
+ * @see _Heap_Protection_block_error().
+ */
+typedef enum {
+  /**
+   * @brief There is an unexpected value in the heap block protector area.
+   */
+  HEAP_ERROR_BROKEN_PROTECTOR,
+
+  /**
+   * @brief There is an unexpected value in the free pattern of a free heap
+   * block.
+   */
+  HEAP_ERROR_FREE_PATTERN,
+
+  /**
+   * @brief There is was an attempt to free the same block twice.
+   */
+  HEAP_ERROR_DOUBLE_FREE,
+
+  /**
+   * @brief The next block of a supposed to be used block does not indicate that
+   * the block is used.
+   */
+  HEAP_ERROR_BAD_USED_BLOCK,
+
+  /**
+   * @brief A supposed to be free block is not inside the heap memory area.
+   */
+  HEAP_ERROR_BAD_FREE_BLOCK
+} Heap_Error_reason;
+
+/**
+ * @brief Context of a heap error.
+ *
+ * @see _Heap_Protection_block_error().
+ */
+typedef struct {
+  /**
+   * @brief The heap of the block.
+   */
+  Heap_Control *heap;
+
+  /**
+   * @brief The heap block causing the error.
+   */
+  Heap_Block *block;
+
+  /**
+   * @brief The heap error reason.
+   */
+  Heap_Error_reason reason;
+} Heap_Error_context;
+
 #ifndef HEAP_PROTECTION
   #define HEAP_PROTECTION_HEADER_SIZE 0
@@ -154,8 +210,14 @@
   );
 
+  typedef void (*_Heap_Protection_error_handler)(
+     Heap_Control *heap,
+     Heap_Block *block,
+     Heap_Error_reason reason
+  );
+
   typedef struct {
     _Heap_Protection_handler block_initialize;
     _Heap_Protection_handler block_check;
-    _Heap_Protection_handler block_error;
+    _Heap_Protection_error_handler block_error;
     void *handler_data;
     Heap_Block *first_delayed_free_block;
Index: cpukit/include/rtems/score/heapimpl.h
===================================================================
--- cpukit/include/rtems/score/heapimpl.h	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ cpukit/include/rtems/score/heapimpl.h	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -380,5 +380,5 @@
   #define _Heap_Protection_block_initialize( heap, block ) ((void) 0)
   #define _Heap_Protection_block_check( heap, block ) ((void) 0)
-  #define _Heap_Protection_block_error( heap, block ) ((void) 0)
+  #define _Heap_Protection_block_error( heap, block, reason ) ((void) 0)
   #define _Heap_Protection_free_all_delayed_blocks( heap ) ((void) 0)
 #else
@@ -401,8 +401,9 @@
   static inline void _Heap_Protection_block_error(
     Heap_Control *heap,
-    Heap_Block *block
+    Heap_Block *block,
+    Heap_Error_reason reason
   )
   {
-    (*heap->Protection.block_error)( heap, block );
+    (*heap->Protection.block_error)( heap, block, reason );
   }
 
Index: cpukit/include/rtems/score/interr.h
===================================================================
--- cpukit/include/rtems/score/interr.h	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ cpukit/include/rtems/score/interr.h	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -139,4 +139,11 @@
    */
   RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE = 12,
+
+  /**
+   * @brief Fatal source for heap errors.
+   *
+   * The fatal code is the address to a heap error context (Heap_Error_context).
+   */
+  RTEMS_FATAL_SOURCE_HEAP = 13,
 
   /**
Index: cpukit/sapi/src/fatalsrctext.c
===================================================================
--- cpukit/sapi/src/fatalsrctext.c	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ cpukit/sapi/src/fatalsrctext.c	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -8,5 +8,5 @@
 
 /*
- * Copyright (c) 2013, 2018 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2013, 2019 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
@@ -40,5 +40,6 @@
   "RTEMS_FATAL_SOURCE_SMP",
   "RTEMS_FATAL_SOURCE_PANIC",
-  "RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE"
+  "RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE",
+  "RTEMS_FATAL_SOURCE_HEAP"
 };
 
Index: cpukit/score/src/heap.c
===================================================================
--- cpukit/score/src/heap.c	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ cpukit/score/src/heap.c	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -148,5 +148,5 @@
         || block->Protection_end.protector [1] != HEAP_END_PROTECTOR_1
     ) {
-      _Heap_Protection_block_error( heap, block );
+      _Heap_Protection_block_error( heap, block, HEAP_ERROR_BROKEN_PROTECTOR );
     }
   }
@@ -154,9 +154,15 @@
   static void _Heap_Protection_block_error_default(
     Heap_Control *heap,
-    Heap_Block *block
+    Heap_Block *block,
+    Heap_Error_reason reason
   )
   {
-    /* FIXME */
-    _Terminate( INTERNAL_ERROR_CORE, 0xdeadbeef );
+    Heap_Error_context error_context = {
+      .heap = heap,
+      .block = block,
+      .reason = reason
+    };
+
+    _Terminate( RTEMS_FATAL_SOURCE_HEAP, (uintptr_t) &error_context );
   }
 #endif
Index: cpukit/score/src/heapallocate.c
===================================================================
--- cpukit/score/src/heapallocate.c	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ cpukit/score/src/heapallocate.c	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -46,5 +46,9 @@
 
         if ( !_Heap_Is_block_in_heap( heap, block_to_free ) ) {
-          _Heap_Protection_block_error( heap, block_to_free );
+          _Heap_Protection_block_error(
+            heap,
+            block_to_free,
+            HEAP_ERROR_BAD_FREE_BLOCK
+          );
         }
 
Index: cpukit/score/src/heapfree.c
===================================================================
--- cpukit/score/src/heapfree.c	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ cpukit/score/src/heapfree.c	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -70,5 +70,5 @@
     for ( current = pattern_begin; current != pattern_end; ++current ) {
       if ( *current != HEAP_FREE_PATTERN ) {
-        _Heap_Protection_block_error( heap, block );
+        _Heap_Protection_block_error( heap, block, HEAP_ERROR_FREE_PATTERN );
         break;
       }
@@ -90,5 +90,5 @@
       _Heap_Protection_check_free_block( heap, block );
     } else {
-      _Heap_Protection_block_error( heap, block );
+      _Heap_Protection_block_error( heap, block, HEAP_ERROR_DOUBLE_FREE );
     }
 
@@ -135,5 +135,5 @@
 
   if ( !_Heap_Is_prev_used( next_block ) ) {
-    _Heap_Protection_block_error( heap, block );
+    _Heap_Protection_block_error( heap, block, HEAP_ERROR_BAD_USED_BLOCK );
     return false;
   }
Index: testsuites/sptests/spinternalerror02/init.c
===================================================================
--- testsuites/sptests/spinternalerror02/init.c	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ testsuites/sptests/spinternalerror02/init.c	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -54,5 +54,5 @@
   } while ( text != text_last );
 
-  rtems_test_assert( source - 3 == RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE );
+  rtems_test_assert( source - 3 == RTEMS_FATAL_SOURCE_HEAP );
 }
 
Index: testsuites/sptests/spinternalerror02/spinternalerror02.scn
===================================================================
--- testsuites/sptests/spinternalerror02/spinternalerror02.scn	(revision f9648baf65ecec2cd01c96557a677ad6ecc06b11)
+++ testsuites/sptests/spinternalerror02/spinternalerror02.scn	(revision 3859cd63afb4cb5f76d125e80f968497478d553f)
@@ -60,4 +60,5 @@
 RTEMS_FATAL_SOURCE_PANIC
 RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE
+RTEMS_FATAL_SOURCE_HEAP
 ?
 ?
