1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0028829: dsetsignal command does not work on Linux properly

OSD::SetSignal() is corrected to unset FPE exceptions on Linux if called with False argument
This commit is contained in:
abv 2017-06-22 22:43:38 +03:00 committed by bugmaster
parent a228288f61
commit 66cfcd0f73
3 changed files with 34 additions and 14 deletions

View File

@ -872,7 +872,6 @@ static void SegvHandler(const int theSignal,
void OSD::SetSignal(const Standard_Boolean aFloatingSignal) void OSD::SetSignal(const Standard_Boolean aFloatingSignal)
{ {
static int first_time = 3 ;
struct sigaction act, oact; struct sigaction act, oact;
int stat = 0; int stat = 0;
@ -894,27 +893,25 @@ void OSD::SetSignal(const Standard_Boolean aFloatingSignal)
} }
#elif defined (__linux__) #elif defined (__linux__)
feenableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW); feenableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
//feenableexcept (FE_INVALID | FE_DIVBYZERO);
fFltExceptions = Standard_True; fFltExceptions = Standard_True;
#endif #endif
} }
else if ( first_time & 1 ) { else
// cout << "SetSignal( Standard_False ) is not implemented..." << endl ; {
first_time = first_time & (~ 1) ; #if defined (__linux__)
fedisableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
fFltExceptions = Standard_False;
#endif
} }
#if defined (sgi) || defined (IRIX ) #if defined (sgi) || defined (IRIX )
if ( first_time & 2 ) { char *TRAP_FPE = getenv("TRAP_FPE") ;
char *TRAP_FPE = getenv("TRAP_FPE") ; if ( TRAP_FPE == NULL ) {
if ( TRAP_FPE == NULL ) {
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
cout << "On SGI you must set TRAP_FPE environment variable : " << endl ; cout << "On SGI you must set TRAP_FPE environment variable : " << endl ;
cout << "set env(TRAP_FPE) \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\" or" << endl ; cout << "set env(TRAP_FPE) \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\" or" << endl ;
cout << "setenv TRAP_FPE \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\"" << endl ; cout << "setenv TRAP_FPE \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\"" << endl ;
#endif #endif
// exit(1) ;
first_time = first_time & (~ 2) ;
}
} }
#endif #endif

View File

@ -2333,6 +2333,13 @@ static Standard_Integer OCC28784(Draw_Interpretor&, Standard_Integer argc, const
return 0; return 0;
} }
static Standard_Integer OCC28829 (Draw_Interpretor&, Standard_Integer, const char**)
{
// do something that causes FPE exception
std::cout << "sqrt(-1) = " << sqrt (-1.) << std::endl;
return 0;
}
void QABugs::Commands_20(Draw_Interpretor& theCommands) { void QABugs::Commands_20(Draw_Interpretor& theCommands) {
const char *group = "QABugs"; const char *group = "QABugs";
@ -2355,6 +2362,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
theCommands.Add("OCC28389", "OCC28389", __FILE__, OCC28389, group); theCommands.Add("OCC28389", "OCC28389", __FILE__, OCC28389, group);
theCommands.Add("OCC28594", "OCC28594", __FILE__, OCC28594, group); theCommands.Add("OCC28594", "OCC28594", __FILE__, OCC28594, group);
theCommands.Add("OCC28784", "OCC28784 result shape", __FILE__, OCC28784, group); theCommands.Add("OCC28784", "OCC28784 result shape", __FILE__, OCC28784, group);
theCommands.Add("OCC28829", "OCC28829: perform invalid FPE operation", __FILE__, OCC28829, group);
return; return;
} }

View File

@ -0,0 +1,15 @@
# check that FPE signals can be both disabled and enabled
pload QAcommands
# start with enabled signals
dsetsignal 1
# first, disable
dsetsignal 0
OCC28829
# then, enable
puts "REQUIRED OCC28829 All: Standard_NumericError"
dsetsignal 1
catch {OCC28829}