You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2014/07/12 03:31:11 UTC

git commit: refs/heads/master - Fix order-of-destruction error in PostingPool.

Repository: lucy
Updated Branches:
  refs/heads/master 9c64ff4ab -> 88e48633b


Fix order-of-destruction error in PostingPool.

Keep the MemoryPool alive while the super destructor runs so that
RawPostings allocated from it are not accessed as dangling references.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/88e48633
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/88e48633
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/88e48633

Branch: refs/heads/master
Commit: 88e48633b0f4eb719e65d2e6306f6836febeb6ee
Parents: 9c64ff4
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Fri Jul 11 18:29:14 2014 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Fri Jul 11 18:29:14 2014 -0700

----------------------------------------------------------------------
 core/Lucy/Index/PostingPool.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/88e48633/core/Lucy/Index/PostingPool.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingPool.c b/core/Lucy/Index/PostingPool.c
index 3207c4c..0deef4a 100644
--- a/core/Lucy/Index/PostingPool.c
+++ b/core/Lucy/Index/PostingPool.c
@@ -121,7 +121,6 @@ PostPool_Destroy_IMP(PostingPool *self) {
     DECREF(ivars->segment);
     DECREF(ivars->polyreader);
     DECREF(ivars->lex_writer);
-    DECREF(ivars->mem_pool);
     DECREF(ivars->field);
     DECREF(ivars->doc_map);
     DECREF(ivars->lexicon);
@@ -134,7 +133,14 @@ PostPool_Destroy_IMP(PostingPool *self) {
     DECREF(ivars->posting);
     DECREF(ivars->skip_stepper);
     DECREF(ivars->type);
+    MemoryPool *mem_pool = ivars->mem_pool;
     SUPER_DESTROY(self, POSTINGPOOL);
+
+    // The MemoryPool must be kept alive while SUPER_DESTROY runs because if
+    // it is destroyed sooner, any RawPosting objects which belong to it will
+    // become dangling references.  SortExternal's destructor will then
+    // malfunction when it traverses the buffer DECREFing each element.
+    DECREF(mem_pool);
 }
 
 int