Hi,

I managed to fix it for the simple test case by clearing core and children
of nodes that will be destroyed. This is done before applying the
changelist, using the following workaround function,.

We still get the warning in our app at some places so I need to work on a
small repro-case for that.

  void clearCoresForNodesAboutToBeDestroyed(OSG::ChangeList* changeList,
bool log)
  {
    std::unordered_map<OSG::Node*, int> nodeRefs;

    // compute final refcount on nodes in changelist
    for (const auto e : *changeList)
    {
      if ((e->uiEntryDesc & (OSG::ContainerChangeEntry::SubReference |
                             OSG::ContainerChangeEntry::AddReference)) == 0)
        continue;

      auto fc =
OSG::FieldContainerFactory::the()->getContainer(e->uiContainerId);
      if (!fc) {
        if (log)
          printf("Container id [%i] not created on this aspect yet\n",
e->uiContainerId);
        continue;
      }

      auto node = dynamic_cast<OSG::Node*>(fc);
      if (!node)
        continue;

      auto i = nodeRefs.find(node);
      if (i == nodeRefs.end())
        i = nodeRefs.insert({ node, node->getRefCount() }).first;

      if (e->uiEntryDesc & OSG::ContainerChangeEntry::SubReference)
        i->second -= 1;

      if (e->uiEntryDesc & OSG::ContainerChangeEntry::AddReference)
        i->second += 1;
    }

    // clear core and chjildren all nodes whose refcount becomes zero
    for (const auto nodeRef : nodeRefs)
    {
      if (nodeRef.second > 0) // won't be deleted here
        continue;

      assert(nodeRef.second == 0);
      auto node = nodeRef.first;

      if (log) {
        printf("Clearing Core & children on Node %p [%i], which is about to
die.\n",
          node, node->getId());
      }

      node->setCore(nullptr);
      node->clearChildren();
    }
  }


Cheers
/Marcus



2017-02-09 9:55 GMT+01:00 Marcus Lindblom Sonestedt <
marcus.lindblom.sonest...@bitaddict.se>:

> Just following up with new findings here.
>
> First, those "entry [xxx] is not null" log messages are not a part of the
> problem, as they disappear if I clear the refs in aspect 0 and apply the
> changelist to aspect 1 again before exiting the test,
>
> Second, the group's parents-field seems to auto-update via execSync, but
> unlinkParent() is called anyway
>
> * Main:  linkParent( node A0) via setCore()
>
> * Thread: applyChangeList A0 -> A1  - linkParent never called on group in
> A1, happens automagicallly?
>
> * Main:  linkParent( clone A0); -> via cloneTree()
>
> * Main:  unlinkParent( node A0); -> via node-destructor as refs => 0 from
> smartptr
>
> * Thread: applyChangeList A0 -> A1, causes these calls, but no linkparent
> for clone A1 to group 1
>    * unlinkParent( node A1) - KABOOM, group's parent list only has clone
> A1.
>       (.. is called via applyAndClear()->subreferencesunrecorded->(node
> A1->resolvelinks()->setCore(null))
>
> So, the unlinkParent(node A1) call via applyAndClear is unnecessary as the
> node is already gone, and we get the warning.
>
> So, the warning seems pretty harmless as the state is correct before
> calling unlinkParent(), but when cloning trees of ~10000 nodes the log
> noise is immense, so we have to filter it out.
>
> That is of course doable, but undesireable, as we get the same error when
> using the wrong aspect-pointers across threads.
>
> Cheers,
> /Marcus
>



-- 
Med vänliga hälsningar,
Marcus Lindblom Sonestedt
*Systemarkitekt*
*BIT ADDICT *- Passion för utveckling
+46 (0)706 43 63 28
marcus.lindblom.sonest...@bitaddict.se
www.bitaddict.se
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to