From 426b6488580a92bf071a62dc319a9c837ce39821 Mon Sep 17 00:00:00 2001 From: "Field G. Van Zee" Date: Wed, 8 Apr 2015 15:12:21 -0500 Subject: [PATCH] Fixed a packing bug that manifested in trsm_r. Details: - Fixed a bug that caused a memory leak in the contiguous memory allocator. Because packm_init() was using simple aliasing when a subpartition object was marked as zeros by bli_acquire_mpart_*(), the "destination" pack object's mem_t entry was being overwritten by the corresponding field of the "source" object (which was likely NULL). This prevented the block from being released back to the memory allocator. But this bug only manifested when changing the location of packing B from outside the var1 loop to inside the var3 loop, and only for trsm with triangular B (side = right). The bug was fixed by changing the type of alias used in packm_init() when handling zero partition cases. Specifically, we now use bli_obj_alias_for_packing(), which does not clobber the destination (pack) object's mem_t field. Thanks to Devangi Parikh for this bug report. --- frame/1m/packm/bli_packm_init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frame/1m/packm/bli_packm_init.c b/frame/1m/packm/bli_packm_init.c index bc267911d..af8a3c32f 100644 --- a/frame/1m/packm/bli_packm_init.c +++ b/frame/1m/packm/bli_packm_init.c @@ -95,10 +95,15 @@ void bli_packm_init( obj_t* a, } // If the object is marked as being filled with zeros, then we can skip - // the packm operation entirely and alias. + // the packm operation entirely and alias. Notice that we use pack-aware + // aliasing. This is needed because the object may have been packed in + // a previous iteration, which means the object currently contains the + // mem_t entry of an already-allocated block. bli_obj_alias_for_packing() + // will avoid overwriting that mem_t entry, which means it can be + // properly released later on. if ( bli_obj_is_zeros( *a ) ) { - bli_obj_alias_to( *a, *p ); + bli_obj_alias_for_packing( *a, *p ); return; }