Hello Martin,

Martin Karlsson wrote:
> Hi Carsten!
> 
> I've tried to use the provided openSG multithreads to solve my problems, 
> but I've run into two different obstacles.
> First problem is in a dummy-program I made just to test the 
> multithreading. Where I wish to add another box to the scene after 5 
> seconds of execution. I've modified the 01hello tutorial file.
> The main-thread is stuck in the glut-main loop, and it's constantly 
> running the display function, witch looks like:

could you post the modified tutorial, please ? I can not spot anything
suspect in the parts below.

> void display(void) {
>     if (needSync == true) {
>        needSync=false;
>        syncBarrier->enter(2);
>        thread->getChangeList()->applyAndClear();
>        syncBarrier->enter(2);
>     }
> 
>     mgr->redraw();
> }
> 
> The other thread is running another function that looks like:
> void foo(void *ptr){
>     sleep(5);
>    
>     // add a box to the scene
>     needSync=true;
>     NodePtr bar = makeBox(2,3,4,1,1,1);
> 
>     // scene is the scene-root, and is a torus.
>     beginEditCP(scene);
>        scene-addChild(bar);
            ^^^^^
this is a copy-paste error, isn't it? scene->addChild(bar)
>     endEditCP(scene);
> 
>     syncBarrier->enter(2);  
>     syncBarrier->enter(2);  
> 
>     // do nothing
>     while(true) {
>        sleep(1);
>        std::cout << "thread lives\n";
>     }
> }
> 
> After the synchronization the scene gets blank and the command prompt 
> gives the warning:
> WARNING:  recurse: core is Null,  don't know what to do!
> How to solve this?

Hm, this means a node without a core was added to the scene, but I have
no idea how or why this happens.

> And the other problem :)
> In another program I'm building, the Barrier seams to fail every now and 
> then, giving the error code:
> *** glibc detected *** double free or corruption (out): 0x082767f0 ***

I'm not sure if this is directly related to the Barrier. That call might
just trigger the glibc routine to check heap consistency. Could you
check if you do not have any stale pointers in use or double free any
memory ?

[SNIP]
> 
> The program crashes most of the time giving the error as I mentioned 
> above. I've noticed that the line: syncBarrier->enter(2); in the display 
> function is what kills the program. syncBarrier is a static variable in 
> the clusterclient class and is declared when constructing a 
> clusterclient object.

Do you define the static member variable, i.e. do you have a line like:

Barrier *ClusterClient::syncBarrier = NULL;

in the ClusterClient.cpp file ?

> osginit and changelist:: setreadwritedefault is 
> declared in the main file, before creating the cluster client object.

the call to ChangeList::setReadWriteDefault must be before the call to
osgInit. Is this the case ?

> How to solve this?

Sorry, I don't really know. There does not seem to be anything in the
snippets you posted. Maybe if we can get the modified tutorial of yours
to work, we might get an idea for your other program, although the
errors are different.

        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