Howdy Ben...
I think that Inventor has always had this "feature"... i.e., you must always
initialize the Inventor database by calling the static SoDB::init() method,
before creating nodes, like SoBlinker, etc....
See page 36 of "The Inventor Mentor":
... "SoDB::init() must be the first Inventor call you make.
If you use the Inventor Component Library, the database is initialized
automatically when you call SoXt::init().
If you are not using components, but you are using interaction or node kits,
or both, call SoInteraction::init(), which initialized the database,
interaction, and node kits."
~MV
***
----- Original Message -----
From: "Ben Wong" <benjamin.wong@xxxxxxxxxxxxx>
To: <info-inventor-dev@xxxxxxxxxxx>
Sent: Friday, May 03, 2002 3:38 AM
Subject: Segfault bug in SoBlinker
> Hi,
>
> It appears that if you allocate an SoBlinker before calling
> SoXt::init(), the program will die with a segmentation fault. This
> doesn't appear to be documented anywhere, nor mentioned on any
> web-page, so I assume it is a bug rather than an obscure feature.
> (Of course, it could just be me doing something silly, but it seems
> unlikely at this point).
>
> I have reproduced the bug on both NetBSD-1.5 with the LGPL version of
> Open Inventor-2.1.5-7 and on an SGI running IRIX 6.5 (with the stock
> Open Inventor). Both died with the same call stack (see below). I'd
> like to know if this bug still exists in the latest version of Open
> Inventor. Could someone please test it for me and post the results?
>
> Below I have included a minimal program to reproduce the bug. Comment
> out the line that defines BLINKBUG if you want to see the program run
> without dumping core.
>
> Ben
>
> --
> College of Computing and GVU
> Benjamin.Wong@xxxxxxxxxxxxx Georgia Institute of Technology
> Atlanta, Georgia 30332-0280
>
> -------- 8< -------- CUT HERE -------- 8< -------- CUT HERE --------
>
> #include <stdlib.h>
> #include <Inventor/SoDB.h>
> #include <Inventor/SoInput.h>
> #include <Inventor/Xt/SoXt.h>
> #include <Inventor/Xt/SoXtRenderArea.h>
> #include <Inventor/nodes/SoBlinker.h>
> #include <Inventor/nodes/SoDirectionalLight.h>
> #include <Inventor/nodes/SoMaterial.h>
> #include <Inventor/nodes/SoPerspectiveCamera.h>
> #include <Inventor/nodes/SoSeparator.h>
> #include <Inventor/nodes/SoCube.h>
>
>
> #define BLINKBUG
>
> // This program exercises a bug in Open Inventor such that if an
> // SoBlinker is allocated *before* SoXt::init() is called, the program
> // will have a segmentation fault.
>
> // This bug was demonstrated on both g++ with Open Inventor 2.1.5-7
> // (NetBSD), and CC with IRIX 6.5's standard Open Inventor.
> //
> // Both die with the same call stack:
>
> //(gdb) bt
> //#0 SbDict::findEntry () at SbDict.c++:182
> //#1 0xc87d3e8 in SbDict::find () at SbDict.c++:160
> //#2 0xc926f34 in find__13SoGlobalFieldSGRC6SbName () at
SoGlobalField.c++:198
> //#3 0xc88af34 in getGlobalField__4SoDBSGRC6SbName () at SoDB.c++:827
> //#4 0xc8de5e4 in SoTimeCounter::__ct () at SoTimeCounter.c++:55
> //#5 0xc9354d8 in SoBlinker::__ct () at SoBlinker.c++:43
> //#6 0x10001c40 in main (argv=0x7fff2f24) at minblinker.cc:25
>
>
> void
> main(int , char **argv)
> {
> #ifdef BLINKBUG
> SoBlinker *myBlinker = new SoBlinker; // THIS CORE DUMPS!
> #endif
>
>
> // Initialize Inventor and Xt
> Widget myWindow = SoXt::init(argv[0]);
> if (myWindow == NULL) exit(1);
>
>
> #ifndef BLINKBUG
> SoBlinker *myBlinker = new SoBlinker; // BUT LATER ALLOCATION IS FINE.
> #endif
>
>
> // Set up camera and light
> SoSeparator *root = new SoSeparator;
> root->ref();
> SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
> root->addChild(myCamera);
> root->addChild(new SoDirectionalLight);
>
> // Setup the scene graph
> root->addChild(myBlinker);
> myBlinker->speed = 1.0/2; // blink every two seconds
> myBlinker->addChild(new SoCube);
>
> // Set up and display render area
> SoXtRenderArea *myRenderArea = new SoXtRenderArea(myWindow);
> SbViewportRegion myRegion(myRenderArea->getSize());
> myCamera->viewAll(root, myRegion);
>
> myRenderArea->setSceneGraph(root);
> myRenderArea->setTitle("Minimal SoBlinker Implementation");
> myRenderArea->show();
> SoXt::show(myWindow);
> SoXt::mainLoop();
> }
>
>
>
|