Hello Martin,

On 5/4/07, Martin Karlsson <[EMAIL PROTECTED]> wrote:
> I've run into another problem. This concerns changelist corruption.
> I'm currently stress testing my application and it crashes within a
> minute or two. And this is due to changelist corruption and/or due to
> lousy object deletion :).

do you have some more details on this, i.e. what makes you believe
this is the problem ?

> The size of the program gets bigger and bigger
> during execution.
>
> The thread that runs the glut main loop looks like this:
> ///// OpenSGClient.cpp
> ....
>
> // callSync is used to synchronize data from the external thread into
> // the glut main thread.
> void OpenSGClient::callSync(){
>          std::cout << "callSync called\n";
>          syncBarrier = Barrier::get(NULL);
>
>          needSync = true;
>          syncBarrier->enter(2);
>          syncBarrier->enter(2);
> }
> void OpenSGClient::display(){
>          if(needSync==true) {
>                  needSync = false;
>                  std::cout << "display have recieved a needSync\n";
>
>                  syncBarrier->enter(2);
>                  std::cout << "display is syncing\n";
> // this line allows new objects to be added to the scenery
> Thread::getCurrentChangeList()->merge(*clientHandle->getChangeList());

Just to avoid future confusion, I'd like to point out that the above
line has not much to do with "being able to add objects to the scene",
it is more like:

// this line fetches changes from the clients change list and makes sure they
// appear in the main threads change list for distribution in the cluster

>
> // this line is used get information of object removal from the scene
>                  clientHandle->getChangeList()->applyAndClear();

same here:

this line modifies the main threads graph to contain the changes made
in the client

>                  syncBarrier->enter(2);
>          }
>
>
>          mgr->redraw();
>          OSG::Thread::getCurrentChangeList()->clearAll();
>          glClear(GL_COLOR_BUFFER_BIT);
>          glutSwapBuffers();
> }
> ....
> ////
>
> In the other thread I use a while(true) loop that first removes all
> objects on the scene. Synchronizes with the other thread. Then it adds a
> random number of objects to the scene, and synchronizes with the other
> thread. This works, but after a random time from one second to two
> minutes the program crashes with the error:
>
> terminate called after throwing an instance of
> 'osg::BinaryDataHandler::ReadError'
>    what():  BinaryDataHandler ReadError: Channel closed

could you post a backtrace for this, please ?

> I get this error when the glut-thread is trying to merge or get the
> changelist from the other thread.
>
> The loop thread looks like this:
> /////// Main.cpp
> ....
> while(true){
>                  //// temporary blob-removal
>                  std::cout << "clean old dots\n";
>                  printf("Number of active blobs: %d\n",activeBlobs.size());
>                  if (activeBlobs.size()>0){
>                         // get the root
>                          NodePtr rootNode = getClient()->getRoot();
>                          beginEditCP(rootNode);
>                                 // remove all of the roots children
>                                  int j = activeBlobs.size();
>                                  for (int i = 0;i<j;i++){
>                           rootNode->subChild(activeBlobs.at(i));
>                                         // ensure child deletion (?)
>                                          subRefCP(activeBlobs.at(i));

subChild decreases the reference count of the removed child. Why do
you call subRefCP manually as well, is there a corresponding addRefCP
call in portions of the code you did not post ?

>                                  }
>
>                          endEditCP(rootNode);
>                          activeBlobs.clear();
>
>                          // Syncronization of changeLists
>                          getClient()->callSync();
>
>                         // get the client changelist - to ensure both
>                         // changelists are identical (?)
> getClientThread()->getChangeList()->applyAndClear();

hm, why this line ? Do you need to pull in changes from the
"getClientThread()"-thread ?
Additionally, it does not seem to be protected by barriers, which
might be the reason for the errors you see.

>                  }
>                  //// end of temporary blob-removal
>
>                 **** add objects to the scene ****
>
> } // end of while loop
> ....
> ////

   Cheers,
    Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to