Hi again,

Some minor changes to cleans up thread and callback so test doesn't crash
on osgExit().

Then I also get these lines in the output:

FieldConnectorFactoryBase::terminate
WARNING: FieldContainerFactoryBase::terminate: Entry [290] is not NULL
([0000000002B7F060]).
WARNING:   [0] [0000000000000000] [] [N/A N/A]
WARNING:   [1] [0000000002BAE0B0] [Group] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [291] is not NULL
([0000000002B7F1E0]).
WARNING:   [0] [0000000000000000] [] [N/A N/A]
WARNING:   [1] [0000000002166CC0] [Node] [1 0]

/Marcus

2017-02-08 17:54 GMT+01:00 Marcus Lindblom Sonestedt <
marcus.lindblom.sonest...@bitaddict.se>:

> Hi all!
>
> We are consistently triggering a probable bug in OpenSG where it complains
> about "link inconsistent" after shallow clone and destroying all refs to
> the original.
>
> This happens on the following sequence of events (which the attached code
> demonstrates)
>
> 1. create node with group core
> 2. apply changelist in another aspect's thread
> 3. clone node with cloneTree (share core)
> 4. clear refereces to original
> 5. apply change list in another aspect's thread again
>
> I've attached the log output (with dumped changelists), if it helps.
>
> The attached code provides a small repro case (testSyncChangeLists) which
> I believe is the minimal code to trigger the bug, and does run on it's own
> (no dependency except the changelist dump).
>
> Before I dig deeper to the cause in OpenSG, are we doing something wrong
> with how we sync changelists/clone objects, or is this a genuine bug?
>
> Cheers,
> --
> Marcus Lindblom Sonestedt
> *Systemarkitekt*
> *BIT ADDICT *- Passion för utveckling
> +46 (0)706 43 63 28
> marcus.lindblom.sonest...@bitaddict.se
> www.bitaddict.se
>
>


-- 
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
//#define NO_CPPUNIT

#ifndef NO_CPPUNIT
#include <cppunit/extensions/HelperMacros.h>
#endif

#pragma warning(disable: 4290) // exception specification ignored

#include <vizOpenSGDebug.h>

#include <OpenSG/OSGGroup.h>
#include <OpenSG/OSGNode.h>
#include <OpenSG/OSGBarrier.h>
#include <string>

using namespace OSG;

class vizAspectsLinkConsistencyTest
#ifndef NO_CPPUNIT
  : public CppUnit::TestFixture
{
  CPPUNIT_TEST_SUITE(vizAspectsLinkConsistencyTest);
  CPPUNIT_TEST(testSyncChangeList);
  CPPUNIT_TEST_SUITE_END();
#else
  {
#endif

public:
  void setUp();
  void tearDown();

  void testSyncChangeList();

  OSG::BarrierRefPtr mSyncBarrier;
  std::string mOsgLog;
};

#ifndef NO_CPPUNIT
CPPUNIT_TEST_SUITE_REGISTRATION( vizAspectsLinkConsistencyTest );
#endif
namespace
{
  void OSGLogBufCallback(const Char8 *data,
    Int32  size,
    void  *clientData)
  {
    auto test = reinterpret_cast<vizAspectsLinkConsistencyTest*>(clientData);

    std::string message(data, size);
    printf("OpenSG aspect %i: %s\n", OSG::Thread::getCurrentAspect(), message.c_str());
    test->mOsgLog += message;

    if (message.find("link inconsistent") != std::string::npos)
      printf("BUG TRIGGERED\n");
  }
}

void vizAspectsLinkConsistencyTest::setUp()
{
  mSyncBarrier = OSG::Barrier::get("vizAspectsLinkConsistencyTest", false);
  mSyncBarrier->setNumWaitFor(2);

  auto& log = OSG::osgLog();
  log.getLogBuf().setCallback(&OSGLogBufCallback, this, true);
  log.setLogType(OSG::LOG_BUFFER);

}


void vizAspectsLinkConsistencyTest::tearDown()
{
  mSyncBarrier = nullptr;

  auto& log = OSG::osgLog();
  log.getLogBuf().removeCallback();
  log.setLogType(OSG::LOG_STDERR);
}

namespace
{
  void runStdFunction(void *args)
  {
    auto func = reinterpret_cast<std::function<void()>*>(args);
    (*func)();
  }
}

void
vizAspectsLinkConsistencyTest::testSyncChangeList()
{
  auto mainThread = OSG::Thread::getCurrent();

  std::function<void()> threadFunc = [&]()
  {
    mSyncBarrier->enter(); // 1

    printf("-- Applying main changelist\n");
    //viz::dumpChangeList(mainThread->getChangeList());
    mainThread->getChangeList()->applyAndClear(); // remove this and bug disappers

    mSyncBarrier->enter(); // 2
    mSyncBarrier->enter(); // 3

    printf("-- Applying main changelist again\n");
    //viz::dumpChangeList(mainThread->getChangeList());
    mainThread->getChangeList()->applyAndClear(); // bug triggers here

    mSyncBarrier->enter(); // 4
  };

  // start thread above
  OSG::ThreadRefPtr thread = Thread::get("testSyncChangeListThread", false);
  thread->runFunction(runStdFunction, 1, &threadFunc);

  // run main thread
  {
    printf("\n-- Creating scenegraph\n");

    OSG::NodePtr scene = OSG::makeCoredNode<OSG::Group>();
    OSG::commitChanges();

    mSyncBarrier->enter(); // 1
    mSyncBarrier->enter(); // 2

    OSG::Thread::getCurrentChangeList()->clear();

    printf("-- Cloning scene graph and applying\n");

    OSG::NodePtr sceneClone = cloneTree(scene); // remove this and bug disappears
    scene = nullptr; // remove this and bug disappears
    OSG::commitChanges();

    mSyncBarrier->enter(); // 3
    mSyncBarrier->enter(); // 4
  }

  mainThread->join(thread);
  thread = nullptr;

#ifndef NO_CPPUNIT
  // disable assert until we fix the issue, but allow us to commit the test
  // CPPUNIT_ASSERT(mOsgLog.find("link inconsistent") == std::string::npos);
#endif
}

#ifdef NO_CPPUNIT

void main(int argc, char* argv[])
{
  OSG::osgInit(argc, argv);

  vizAspectsLinkConsistencyTest test;

  test.setUp();
  test.testSyncChangeList();
  test.tearDown();
}

#endif
------------------------------------------------------------------------------
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