[omniORB] LOCATION_FORWARD exception from a python method

baileyk at schneider.com baileyk at schneider.com
Mon Dec 15 10:56:11 GMT 2003



Below is a stripped down test program which goes through all the same steps
as the real system.  I get the same SEGV stack as before on Solaris 8 with
the latest CVS snapshot of omniORB and omniORBpy.  I'm using Python v2.2.1,
and the C/C++ compiler is Sun Workshop C/C++ 5.3.

This is self-contained, using omniORB.importIDL() to compile some IDL at
runtime.

Thanks,
Kendall


# ------------TEST PROGRAM STARTS HERE-------------
import CORBA, omniORB
import sys, time
import PortableServer, PortableServer__POA

idl = """
module LF_Bug {
   interface Tester {
      string run( in string arg0, out string arg1 );
   };

   interface Repo {
      Object getRefQualified( in string flavor );
   };
};
"""
mods = omniORB.importIDLString( idl )
LF_Bug = sys.modules['LF_Bug']
LF_Bug__POA = sys.modules['LF_Bug__POA']

# global variables
refA     = None # corba ref to servantA
refB     = None # corba ref to servantB
imref    = None # corba ref to repo

#------------------------------------------------------------
def mkout( strm ):
   def write( x, strm = strm ):
      strm.write( "%.3f : %s\n" % (time.time(), x) )
      strm.flush()
   return write

#------------------------------------------------------------
class RepoLocator( PortableServer__POA.ServantLocator):
   def __init__(self, poa ):
      self.poa = poa
      self.log = mkout(sys.stdout)
   #-------------------------------------
   def _default_POA(self):
      return self.poa
   #-------------------------------------
   def preinvoke(self, oid, poa, op):
      global refA, refB
      if oid.startswith('A') :
         self.log('locator redirecting to refA')
         raise PortableServer.ForwardRequest( refA )
      else :
         self.log('locator redirecting to refB')
         raise PortableServer.ForwardRequest( refB )
   #-------------------------------------
   def postinvoke(self,oid,poa,op,cookie,servant):
      pass

#-------------------------------------------------------------
class Repo( LF_Bug__POA.Repo ) :
   def __init__(self, poa ):
      self.poa = poa
      pol = [
         self.poa.create_request_processing_policy(
            PortableServer.USE_SERVANT_MANAGER),
         self.poa.create_servant_retention_policy(
            PortableServer.NON_RETAIN),
         self.poa.create_id_assignment_policy(
            PortableServer.USER_ID),
         self.poa.create_lifespan_policy(
            PortableServer.PERSISTENT) ]
      self.repo_poa = self.poa.create_POA(
           "implRepo", self.poa._get_the_POAManager(), pol )
      self.locator = RepoLocator( self.poa )
      self.locref = self.locator._this()
      self.repo_poa.set_servant_manager( self.locref )
      self.log = mkout(sys.stdout)
   def _default_POA(self):
      return self.poa
   def getRefQualified(self, flavor):
      self.log('Repo generating an indirect ref to flavor %s' % flavor)
      return self.repo_poa.create_reference_with_id(
             flavor, 'IDL:LF_Bug/Tester:1.0' )

#-------------------------------------------------------------
class Servant( LF_Bug__POA.Tester ):
   def __init__( self, poa, rv, flavor = 'A' ):
      self.poa = poa
      self.rv = rv
      self.flavor = flavor
      self.log = mkout(sys.stdout)
   def _default_POA( self ):
      return self.poa
   def run(self, arg0):
      global imref
      if arg0.startswith(self.flavor) :
         self.log('Servant request with proper flavor %s' % self.flavor)
         return self.rv, arg0[1:]
      else :
         self.log('Servant request with wrong flavor %s' % arg0[0] )
         ref = imref.getRefQualified( arg0[0] )
         self.log('Servant redirecting to ref %s' % str(ref))
         raise omniORB.LOCATION_FORWARD( ref )

#-------------------------------------------------------------
def main():
   global imref, refA, refB
   out = mkout(sys.stdout)
   orb = CORBA.ORB_init( sys.argv )
   rootpoa = orb.resolve_initial_references("RootPOA")
   rootpoa._get_the_POAManager().activate()
   repo = Repo( rootpoa )
   servantA = Servant(rootpoa, 'servantA', 'A')
   servantB = Servant(rootpoa, 'servantB', 'B')
   refA = servantA._this()
   refB = servantB._this()
   imref = repo._this()
   imref = imref._narrow( LF_Bug.Repo )

   # the indirect refs will get calls redirected to flavor 'A'
   # servant.  If we call on that with a 'B' requests, it should
   # trigger a flurry of activity:
   # 1. servantA will call on the imref to get a new indirect reference
   # 2. servantA will raise the omniORB.LOCATION_FORWARD
   # 3. the client will use that new reference, which again hits the
locator
   # 4. The locator should throw a PortableServer.ForwardRequest
   # 5. The client should then re-try on servant B and succeed

   # try a flavor A request, which should work
   indirectRefA = imref.getRefQualified( 'A' )
   tref = indirectRefA._narrow( LF_Bug.Tester )
   out( 'flavor A request on flavor A indirect reference start' )
   result = tref.run('AHello')
   out( 'complete with %s' % str(result) )

   # try a flavor B request, which causes SEGV
   indirectRefA = imref.getRefQualified( 'A' )
   tref = indirectRefA._narrow( LF_Bug.Tester )
   out( 'flavor B request on flavor A indirect reference start' )
   result = tref.run('BHello')
   out( 'complete with %s' % str(result) )

if __name__ == "__main__" :
   main()

# END OF TEST PROGRAM



                                                                                                                                           
                      Duncan Grisby                                                                                                        
                      <duncan at grisby.org>                  To:       baileyk at schneider.com                                                 
                      Sent by:                             cc:       omniorb-list at omniorb-support.com                                      
                      omniorb-list-bounces at omniorb-        Fax to:                                                                         
                      support.com                          Subject:  Re: [omniORB] LOCATION_FORWARD exception from a python method         
                                                                                                                                           
                                                                                                                                           
                      12/15/2003 06:16 AM                                                                                                  
                                                                                                                                           
                                                                                                                                           




On Friday 12 December, baileyk at schneider.com wrote:

> I'm getting a SEGV from omni::locationForward() during a test case where
a
> python servant method throws a omniORB::LOCATION_FORWARD exception
because
> new_location.pd_id is null.

This is odd. I've looked into it, and I've found a bug in the way
location forwards are handled that lead to a segfault. However, it
doesn't segfault in the place you mention.

Please can you try the current CVS version (or a snapshot -- I've
updated it), and see if that helps. If you still get the segfault, can
you send me an example program that prompts it?

Cheers,

Duncan.

--
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --

_______________________________________________
omniORB-list mailing list
omniORB-list at omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list








More information about the omniORB-list mailing list