# HG changeset patch # User Yasumasa Suenaga # Date 1484558690 -32400 # Node ID 2b0645fd51d3a96b5b4b4f352f50962507c605f3 # Parent 55659802313d698b8124c2603e095f8621af7f24 Bug 3104: SEGV in TSnapShotContainer::mergeChildren with Oracle JDK8u92 Reviewed-by: ykubota diff -r 55659802313d -r 2b0645fd51d3 agent/ChangeLog --- a/agent/ChangeLog Thu Nov 24 14:42:03 2016 +0900 +++ b/agent/ChangeLog Mon Jan 16 18:24:50 2017 +0900 @@ -1,3 +1,7 @@ +2017-01-16 Yasumasa Suenaga + + * Bug 3104: SEGV in TSnapShotContainer::mergeChildren with Oracle JDK8u92 + 2016-11-24 KUBOTA Yuji * Bump to 1.1.5 diff -r 55659802313d -r 2b0645fd51d3 agent/src/snapShotContainer.cpp --- a/agent/src/snapShotContainer.cpp Thu Nov 24 14:42:03 2016 +0900 +++ b/agent/src/snapShotContainer.cpp Mon Jan 16 18:24:50 2017 +0900 @@ -1,7 +1,7 @@ /*! * \file snapshotContainer.cpp * \brief This file is used to add up using size every class. - * Copyright (C) 2011-2013 Nippon Telegraph and Telephone Corporation + * Copyright (C) 2011-2017 Nippon Telegraph and Telephone Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -593,23 +593,48 @@ /* Loop each children class. */ TChildClassCounter *counter = srcClsCounter->child; + TChildClassCounter *prevCounter = NULL; while (counter != NULL){ - /* Search child class. */ - TChildClassCounter *childClsData = - this->findChildClass(clsCounter, counter->objData->klassOop); - - /* Register class as child class. */ - if(unlikely(childClsData == NULL)){ - childClsData = this->pushNewChildClass( - clsCounter, counter->objData); - } - - if(likely(childClsData != NULL)){ - /* Marge children class heap usage. */ - this->addInc(childClsData->counter, counter->counter); + TObjectData *objData = counter->objData; + + /* + * If the class of objData is already unloaded, we should + * remove reference to it from child object data. + */ + if (objData->isRemoved) { + TChildClassCounter *nextCounter = counter->next; + + if (prevCounter == NULL) { + srcClsCounter->child = nextCounter; + } else { + prevCounter->next = nextCounter; + } + + /* Deallocate TChildClassCounter. */ + free(counter->counter); + free(counter); + + counter = nextCounter; + } else { + /* Search child class. */ + TChildClassCounter *childClsData = + this->findChildClass(clsCounter, objData->klassOop); + + /* Register class as child class. */ + if (unlikely(childClsData == NULL)) { + childClsData = + this->pushNewChildClass(clsCounter, objData); + } + + if (likely(childClsData != NULL)) { + /* Marge children class heap usage. */ + this->addInc(childClsData->counter, counter->counter); + } + + prevCounter = counter; + counter = counter->next; } - counter = counter->next; } }