[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

3426.0. "Signal PIPE received when catching or throwing exception???" by TAEC::SANNA () Tue Feb 04 1997 08:00

Bonjour,


It seems I have a random problem :
	sometimes, I get a broken pipe either at :
	>>	catch (GAT_ICG_COMMUNICATION_EXCEPTION &exc)
		{
			exc.SetCommunicationType(GAT_K_ICG_COMM_SEND_RECEIVE);
			throw exc;
		}
	or at :
		catch (GAT_ICG_EXCEPTION)
		{
	>>		throw;
		}

The second one is the catching of the exception thrown in the first one.

I can't understand why I receive a signal PIPE when handling exceptions, and I
don't know where to look for a solution...
Can anyone help me with this????

Attached below :
	*reference of OS and compiler
	*source code.

Thanks and regards,
Isa.
-------------------------------------------
$what_is_installed CXX
CXXBASE540      installed       DEC C++ (cxx) for Digital UNIX
CXXLIB540       installed       DEC C++ static class libraries
CXXMAN540       installed       DEC C++ and class library manual pages
CXXSHRDA307     installed       DEC C++ Class Library, Run-Time Support
CXXV3HDR540     installed       DEC C++ header files for Digital UNIX V3.x
CXXV51CXX530    installed       DEC C++ V5.1 (v51cxx) for Digital UNIX
CXXV53CXX540    installed       DEC C++ Version 5.3 (v53cxx) for Digital UNIX

$cxx -V
cxx  (cxx)
DEC C++ V5.4-006 on Digital UNIX (Alpha)

$uname -a
OSF1 havane.vbo.dec.com V3.2 148 alpha


Note : DecLadebug 4.0-26 doesn't give more info than : 
Thread received signal PIPE
stopped at [void Instruction03(GAT_ICG_CONTROL_COMMAND&, GAT_ICG_CONTEXT&,
GAT_ICG_AUTOMATON&):380 0x3ff81826a90]



My exception classes are :
--------------------------
class GAT_ICG_EXCEPTION
{
public:
  //constructors
  GAT_ICG_EXCEPTION() : code(GAT_K_ICG_EXCEP_UNKNOWN_ERROR), msg("") {};

  GAT_ICG_EXCEPTION(const String &m) : code(GAT_K_ICG_EXCEP_UNKNOWN_ERROR), msg(m)
{};

  GAT_ICG_EXCEPTION(GAT_T_ICG_EXCEPTION_CODE_ENUMERATION c, const String &m) :
code(c),
msg(m) {};

   //copy constructor
  GAT_ICG_EXCEPTION(const GAT_ICG_EXCEPTION& other) : code(other.code),
msg(other.msg)
{};

  //destructor
  ~GAT_ICG_EXCEPTION() {};

  GAT_T_ICG_EXCEPTION_CODE_ENUMERATION GetCode(void) const { return code;};
 const String &GetMsg(void) const { return msg;};

  void SetMsg(const String &m) {msg = m;};

private:
  GAT_T_ICG_EXCEPTION_CODE_ENUMERATION code;
  String msg;
  
};




class GAT_ICG_COMMUNICATION_EXCEPTION : public GAT_ICG_EXCEPTION
{
public:
  //constructor
   GAT_ICG_COMMUNICATION_EXCEPTION(const String &m) :			 
		GAT_ICG_EXCEPTION(GAT_K_ICG_EXCEP_COMMUNICATION_ERROR,m), 	
		commType(GAT_K_ICG_COMM_CONNECT) {};

  GAT_ICG_COMMUNICATION_EXCEPTION(const String &m, 
				  GAT_T_ICG_COMM_ACTION_TYPE_ENUMERATION comm) : 
		GAT_ICG_EXCEPTION(GAT_K_ICG_EXCEP_COMMUNICATION_ERROR,m),
		commType(comm) {};


  //copy constructor
  GAT_ICG_COMMUNICATION_EXCEPTION(const  GAT_ICG_COMMUNICATION_EXCEPTION &other) : 
		GAT_ICG_EXCEPTION(other), 
		commType(other.commType) {};


  //destructor
  ~GAT_ICG_COMMUNICATION_EXCEPTION() {};


  GAT_T_ICG_COMM_ACTION_TYPE_ENUMERATION GetCommunicationType(void) const { return
commType;};

  void SetCommunicationType(GAT_T_ICG_COMM_ACTION_TYPE_ENUMERATION comm) { commType
=
comm;};
  

private:
  GAT_T_ICG_COMM_ACTION_TYPE_ENUMERATION commType;
};



The "guilty" code is :
-----------------------
Notes :
* lines where the signal seems to be received are  /*******/
* The exception is thrown in GAT_ICG_BLOCK_COMMUNICATION::Call at line /*EEEEEEE*/


void Instruction03 (GAT_ICG_CONTROL_COMMAND& command, GAT_ICG_CONTEXT& context,
GAT_ICG_AUTOMATON& automaton)
{
  MTraceStream trace1(GAT_K_CO_IN_OUT | GAT_K_ICG_PROTOCOL);
  MTraceStream trace2(GAT_K_CO_EXCEPTION | GAT_K_ICG_PROTOCOL);
  MTraceStream trace3(GAT_K_ICG_PROTOCOL);
  trace1 << "Entering Instruction03 : SendReceive." << endl;

  try
    {
      //format command before sending it
      automaton.messageFormatter.Process(command,context);      

      trace3 << "Format has been successful." << endl;

      //send the command to CS, get response msg and put it into the command
/* EXCEPTION IS THROWN IN THIS STATEMENT */
      automaton.communication.SendReceive(command,context);

      trace3 << "SendReceive has been successful." << endl;

      //analyze the msg received
      automaton.responseAnalyzer.Process(command,context);

      trace3 << "Response Analyzis has been successful." << endl;

      //set the event according to the response status returned by the parser
      automaton.currentEvent =
(GAT_T_ICG_EVENT_ENUMERATION)automaton.responseAnalyzer.GetLastStatus();

      //automaton has to process according to the response status
      automaton.SetMore();
    }
  catch (GAT_ICG_EXCEPTION)
    {
/*********/      throw;
    }
  catch (...)
    {
      String errorMsg = context.GetCatalogMsg(GAT_K_ICG_MESS40,"Unclassified
processing
error.");

      trace2 << "Throw an ICG processing exception in Instruction03 : ";
      trace2 << (const char*)errorMsg << endl;

      throw GAT_ICG_PROCESSING_ERROR(errorMsg);
    }

  trace1 << "Exiting Instruction03 : SendReceive." << endl;
}





void GAT_ICG_BLOCK_COMMUNICATION::SendReceive(
  GAT_ICG_CONTROL_COMMAND& command,
  GAT_ICG_CONTEXT &context
)
{
  MTraceStream trace1(GAT_K_CO_IN_OUT | GAT_K_ICG_COMM | GAT_K_ICG_INTERNAL);
  MTraceStream trace2(GAT_K_CO_EXCEPTION | GAT_K_ICG_COMM);
  MTraceStream trace3(GAT_K_ICG_COMM);  
  trace1 << "Entering GAT_ICG_BLOCK_COMMUNICATION::SendReceive for command " <<
(const
char*)command.GetIdentifier() << endl;

  //verify that the call has been initiated and that the command is a send-receive
one 
  if (command.GetType() == GAT_K_ICG_SEND_RECEIVE)
    {
      if (commServerCall.More())
	{
	  try
	    {
	      MEnumeration callTypeParam = GAT_K_CS_SEND_RECEIVE;
	      //set the type of the DIALOGUE call
	      callTypeParam.PutCallParameter(commServerCall,
MCC_K_ARG_DIALOGUE_CC_MESSAGE_TYPE);
	      
	      //set the timer parameter of the DIALOGUE call
	      if ( command.HasTimer() )
		{
		  MBinRelTim timerParam(command.GetTimer());
		  trace3 << "Set timer argument of the call to "  <<
(MCC_T_Integer32)timerParam << "s." << endl;

		  //check that timer > 0
		  String errorMsg = context.GetCatalogMsg(GAT_K_ICG_MESS33,"Null
timer
is not allowed for command with type connect, send-receive or send-redirect.");
		  GAT_ICG_ValidTimer(timerParam,errorMsg);
		 
timerParam.PutCallParameter(commServerCall,MCC_K_ARG_DIALOGUE_CC_TIMEOUT);
		}
	      
	      MOctetString commandParam = (char *) command.GetFormattedCommand();
	      
	      trace3 << "Set command argument of the call to " << commandParam <<
endl;
	      
	      //verify that the call has been initiated      
	      commandParam.PutCallParameter(commServerCall,
MCC_K_ARG_DIALOGUE_CC_COMMAND);
	      
	      trace3 << "Call Communication Server" << endl;
/* EXCEPTION IS THROWN IN THIS STATEMENT */
	      Call(context);
	  
	      //Get the message from the DIALOGUE call and put it into the command
	      MOctetString messageParam;
	     
messageParam.GetCallParameter(commServerCall,MCC_K_ARG_DIALOGUE_RES_CC_MESSAGE);
	      
	      trace3 << "Message received from CS is : " << messageParam << endl;
	      
	      command.SetReceivedMsg((const char*) messageParam);

	      //signal that a msg has been received from the NE
	      context.SetActive();
	    }
/*********/ catch (GAT_ICG_COMMUNICATION_EXCEPTION &exc)
	    {
	      exc.SetCommunicationType(GAT_K_ICG_COMM_SEND_RECEIVE);
	      throw exc;
	    }
	  catch (GAT_ICG_EXCEPTION)
	    {
	      throw;
	    }
	  catch (...)
	    {
	      trace3 << "A non communication exception has been catched in
SendReceive."
<< endl;

	      String errorMsg = context.GetCatalogMsg(GAT_K_ICG_MESS01,"Unclassified
communication error.");

	      trace2 << "Throw an ICG communication exception in
GAT_ICG_BLOCK_COMMUNICATION::SendReceive : ";
	      trace2 << (const char*)errorMsg << endl;

	      throw
GAT_ICG_COMMUNICATION_EXCEPTION(errorMsg,GAT_K_ICG_COMM_SEND_RECEIVE);
	    }
	}//call is not more
      else
	{
	  String errorMsg = context.GetCatalogMsg(GAT_K_ICG_MESS02,"Unvalid handle
in
call to Communication Server.");

	  trace2 << "Throw an ICG communication exception in
GAT_ICG_BLOCK_COMMUNICATION::SendReceive : ";
	  trace2 << (const char*)errorMsg << endl;
	  
	  throw
GAT_ICG_COMMUNICATION_EXCEPTION(errorMsg,GAT_K_ICG_COMM_SEND_RECEIVE);
	}
    }//command is not send-receive
  else
    {
      String errorMsg = context.GetCatalogMsg(GAT_K_ICG_MESS41,"Unvalid access to
the
communication block within ICG protocol.");

      trace2 << "Throw an ICG processing error exception in
GAT_ICG_BLOCK_COMMUNICATION::SendReceive : ";
      trace2 << (const char*)errorMsg << endl;

      throw GAT_ICG_PROCESSING_ERROR(errorMsg);
    }

  trace1 << "Exiting GAT_ICG_BLOCK_COMMUNICATION::SendReceive for command " << endl;
}



void GAT_ICG_BLOCK_COMMUNICATION::Call(
  const GAT_ICG_CONTEXT &context
)
{
  MTraceStream trace1(GAT_K_CO_IN_OUT | GAT_K_ICG_COMM);
  MTraceStream trace2(GAT_K_CO_EXCEPTION | GAT_K_ICG_COMM);  
  MTraceStream trace3(GAT_K_ICG_COMM | GAT_K_ICG_INTERNAL);  
  trace1 << "Entering GAT_ICG_BLOCK_COMMUNICATION::Call."<< endl;

  //initiate the call to the CS
  MCC_T_CVR callStatus = commServerCall.CallAccess();
  MCC_T_Unsigned32 callResponse = commServerCall.GetResponse();
  
  //Analyze the call status
  if (callStatus ==  MCC_S_SPECIALIZED_EXCEPTION)
    {
      trace3 << "DIALOGUE call ended with a specialized exception." << endl;

      String errorMsg = dialogueDirective.GetException(callResponse).GetReplyText();

      switch (callResponse)
	{
	case MCC_K_EXC_DIALOGUE_CC_CONNECT_FAILED:
	case MCC_K_EXC_DIALOGUE_CC_SEND_FAILED:
	  {
	    MLatin1String errorInfo = "";
	    MUnsigned32 errorCode;
	    String tmpCode = "";

	    //Get error message argument and add it to the error msg
	   
errorInfo.GetCallParameter(commServerCall,MCC_K_ARG_DIALOGUE_CC_ERROR_MESSAGE);
	    errorMsg += " ";
	    errorMsg += errorInfo;

	    errorMsg += " ";
	    errorMsg += context.GetBase().GetCatalogMsg(GAT_K_ICG_MESS05,"Error
code and
source are (code / source) : ");

	    //get error code argument and add it to the error msg
	   
errorCode.GetCallParameter(commServerCall,MCC_K_ARG_DIALOGUE_CC_ERROR_CODE);
	    strstream converter;
	    converter << errorCode;
	    converter >> tmpCode;
	    errorMsg += tmpCode;
	    errorMsg += " / ";

	   
errorInfo.GetCallParameter(commServerCall,MCC_K_ARG_DIALOGUE_CC_ERROR_SOURCE);
	    errorMsg += errorInfo;
	    break;
	  }
	default:
	  {
	    break;
	  }
	}

      trace2 << "Throw communication exception : " << callResponse << endl;
      trace2 << (const char*)errorMsg << endl;
/*EEEEEEE*/      throw GAT_ICG_COMMUNICATION_EXCEPTION(errorMsg);
    }
  else if (callStatus ==  MCC_S_COMMON_EXCEPTION)
    {
      trace3 << "DIALOGUE ended with a common exception." << endl;      

      String errorMsg = context.GetCatalogMsg(GAT_K_ICG_MESS03,"Problem during the
call
to the comm server");
      trace2 << "Throw communication exception : " << callResponse << endl;
      trace2 << (const char*)errorMsg << endl;
      throw GAT_ICG_COMMUNICATION_EXCEPTION(errorMsg);
    }

  trace1 << "Exiting GAT_ICG_BLOCK_COMMUNICATION::Call."<< endl;
}



T.RTitleUserPersonal
Name
DateLines
3426.1try looking at objects getting destructedDECC::SEIGELTue Feb 04 1997 17:5713
DEC C++ exceptions support does not use signals or pipes, hence it is unlikely
that it is the cause of your SIGPIPE problem.

Note that when an exception gets handled, destructors get called for objects
whose scopes are being exitted (between the point the exception is thrown and
the point it is handled).  Perhaps one of the destructors for one of your
objects is doing something that is causing the SIGPIPE.

Also, copy constructors are sometimes called for objects being thrown.  These
copy constructors could also be doing something to cause the SIGPIPE.


Harold
3426.2signal mask not restored properly by libexcDECC::SEIGELFri Feb 07 1997 13:262
See note 8748 in Digital_Unix note conference for the resolution of this
problem.  It's a bug in the Unix v3.2 version of libexc.
3426.3Do we also need a patched cxx lib ?TAEC::FLAUWMarc Flauw, TeMIP Technical Office, VBOFri Feb 07 1997 14:2474
Hello,

It seems the problem of .0 is due to a problem in libexc.a.

From note 8478.1:

#It used to be that the C++ rtl had its own copy of libexc.a -- if that's still
#true on V3.2C, you'll need a patched C++ library.

Can you clarify whether we also need a patched libcxx ?

Our environment is both Unix V3.2C and Unix V3.2G, depending on product
version.

Thanks and regards,

Marc.
-------------------------------------------------------
       <<< TURRIS::DISK$NOTES_PACK2:[NOTES$LIBRARY]DIGITAL_UNIX.NOTE;1 >>>
                               -< DIGITAL UNIX >-
================================================================================
Note 8748.1    signals mask modified when handling C++ exceptions         1 of 1
SMURF::DENHAM "Digital UNIX Kernel"                  50 lines   7-FEB-1997 09:08
--------------------------------------------------------------------------------
    This is a known bug. Whether you can patch it yourself depends
    on how you have to link the C++ application. It used to be that
    the C++ rtl had its own copy of libexc.a -- if that's still true
    on V3.2C, you'll need a patched C++ library.
    
    Otherwise, you need to pick up this patched libexc.a and relink
    your application.
    
    PROBLEM:        (Case ID: EVT101544)            (Patch ID: OSF350-102)
    ********
    
    Programs linked with the libexc.a library can have their process signal
    masks corrupted while handling exceptions at runtime. Theproblem shows
    up when the process stops responding to signals. The ps -s command
    shows a mask of random signals blocked, including the one required to
    make the program function correctly.
    
    Ada and C++ programs seems to the most likely to experience the
    program.
    
    
    FILE(s):
    
    /usr/ccs/lib/cmplrs/cc/libexc.a         subset OSFCMPLRSEXT350
    CHECKSUM: 09358     23
    --------------------------------------------------------------
    
    INSTALLATION INSTRUCTIONS:
    
    Become superuser and execute the following commands:
    
    # cd /usr/ccs/lib/cmplrs/cc
    # cp /patches/libexc.a libexc.a.new
    # chown bin:bin libexc.a.new
    # chmod 644 libexc.a.new
    # ln libexc.a libexc.a.orig
    # mv libexc.a.new libexc.a
    
    
    And please don't ask me how to get the patch. The patch thing has
    been in such state lately, I have no idea.
    
    The problem here is a mismatch between the kernel's and the exc
    library's expectations about restoring the signal mask. The library
    never made a change is was supposed to for V3 and is passing
    a garbage signal mask in a sigreturn call when going a longjmp....
    
    
    
    
3426.4libcxx is fine (if you have the existing eco)HNDYMN::MCCARTHYA Quinn Martin ProductionFri Feb 07 1997 15:574
I think you have the "latest" ECO of libcxx - which is linked with a 
fixed version of libexc.a so things going thorugh libcxx.so will be fine.

Brian J.