jirentabu / crashrpt

Automatically exported from code.google.com/p/crashrpt
0 stars 0 forks source link

Possible error when registering signal handlers. #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In CrashHandler.cpp in the function SetProcessExceptionHandlers(),
the code reads.

  if(dwFlags&CR_INST_SIGILL_HANDLER)
  {
    // Catch illegal instruction handler
    m_prevSigINT = signal(SIGINT, SigintHandler);     
  }

  if(dwFlags&CR_INST_TERMINATE_HANDLER)
  {
    // Catch a termination request
    m_prevSigTERM = signal(SIGTERM, SigtermHandler);          
  }

on the other hand, CR_INST_SIGINT_HANDLER and CR_INST_SIGTERM_HANDLER are never 
used.
Maybe they were intended to be used here and the above has two typos?

I have not tested this and I am not familiar enough with signal() and its side 
effects to be sure.

Original issue reported on code.google.com by Schoenle...@googlemail.com on 19 Sep 2011 at 4:58

GoogleCodeExporter commented 9 years ago
I'm not sure this is a bug. Although CR_INST_SIGINT_HANDLER and 
CR_INST_SIGTERM_HANDLER are never used in CrashRpt code, a client application 
can set these flags. Even if the client application specifies 0 as dwFlags 
parameter, the following code in the beginning of 
CCrashHandler::SetThreadExceptionHandlers() will set all bits to 1, which is 
equivalent to specifying CR_INST_SIGINT_HANDLER and CR_INST_SIGTERM_HANDLER:

  // If 0 is specified as dwFlags, assume all available exception handlers should be
  // installed  
  if((dwFlags&0x1FFF)==0)
    dwFlags |= 0x1FFF;

Original comment by zexspect...@gmail.com on 20 Sep 2011 at 3:07

GoogleCodeExporter commented 9 years ago

Original comment by zexspect...@gmail.com on 9 Oct 2011 at 3:48