Re: Seg fault in PortableServer_POA_activate_object function



K.

Your code is almost similar--but you're not checking your
CORBA_Environment variable (ev) for exceptions after each ORB call. 
Have a look at my usage of the THROW macro in my code.  While your code
*is* similar, error checking aside, there are likely lots of things that
could go wrong at runtime and cause one of your ORB calls to fail.  For
example, if your call to CORBA_ORB_resolve_initial_references() fails
then you'll have an invalid root_poa, and in that case it wouldn't
surprise me at all if your subsequent call to impl_Calculator__create()
segfaulted...  Also if a failure *did* occur then the THROW macro will
print the text of the CORBA exception providing further clues into your
dilemma...

Good luck,
M.

On Wed, 2002-04-24 at 11:04, Katherine Goude wrote:
> Thanks for the suggestions Mark but I still can't work out the cause of the
> error!
> 
> > K.
> >
> > Lots of things could be causing your segfault, but chances are you
> > didn't initialize something properly or allocate space for your ev
> > struct.  It's hard to say without seeing your code.
> 
> My server code looks very similar to your example below. This is part of the
> main function:
> ...
> ...
> 
>   CORBA_Environment*        ev;
> ...
> ...
> 
>   ev = g_new0(CORBA_Environment,1);
> 
>    CORBA_exception_init(ev);
> 
>    orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", ev);
>    //debug statement
>    printf("Initialised orb\n");
> 
>    root_poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(orb,
> "RootPOA", ev);
>    //debug statement
>    printf("Initialised poa\n");
> 
>    calculator = impl_Calculator__create(root_poa, ev);
>    //debug statement
>    printf("Created calculator\n");
> ...
> ...
> 
> 
> When I run this, the output to the screen is:
> Initialised orb
> Initialised poa
> Segmentation fault (core dumped)
> 
> I've checked and triple checked everything and it looks correct so any other
> ideas?
> 
> Katherine
> 
> >
> >
> > A while ago I wrote a similar test program (only for ORBit 0.5.12) with
> > an interface called Fortune to return fortunes from remote servers.  My
> > server initialization code looked something like this:
> >
> > #define THROW if (ev->_major != CORBA_NO_EXCEPTION) {           \
> > g_error("CORBA Exception:  %s", CORBA_exception_id(ev)); }
> >
> > ...
> >
> >     /* Initialize the CORBA environment. */
> >
> >     ev = g_new0(CORBA_Environment, 1);
> >     CORBA_exception_init(ev);
> >     THROW;
> >     orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", ev);
> >     THROW;
> >
> >     /* Snag the root POA and instantiate my server. */
> >     root_poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references
> >         (orb, "RootPOA", ev);
> >     THROW;
> >     fortune = impl_Fortune__create(root_poa, ev);
> >     THROW;
> >
> > Notice two things:  first, I've allocated space for my ev struct;
> > second, I *always* checked for failures after each ORB call that might
> > report one...  It's possible you're trying to use the root POA after
> > having failed to get a reference.
> 
> _______________________________________________
> orbit-list mailing list
> orbit-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/orbit-list
-- 
Mark Pedersen
ITA Software, Inc.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]