mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030775: Foundation Classes - Preserve application-defined top-level exception filter
OSD::SetSignal() method now accepts argument resetting handler to default. Added new method OSD::SetThreadLocalSignal() intended to setup thread-specific handlers (e.g. _set_se_translator() on Windows) and FPE settings. OSD_ThreadPool now uses new method instead of OSD::SetSignal(). dsetsignal syntax has been changed so that the first argument now defines of signals should be catched by OCCT or not; new parameter -fpe defines if FPE signals should be catched.
This commit is contained in:
@@ -908,21 +908,71 @@ static int dperf (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char
|
||||
|
||||
static int dsetsignal (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
|
||||
{
|
||||
// arm FPE handler if argument is provided and its first symbol is not '0'
|
||||
// or if environment variable CSF_FPE is set and its first symbol is not '0'
|
||||
bool setFPE = false;
|
||||
if (theArgNb > 1)
|
||||
if (theArgNb < 2)
|
||||
{
|
||||
setFPE = (theArgVec[1][0] == '1' || theArgVec[1][0] == 't');
|
||||
theDI << "Catch signals: " << (OSD::ToCatchSignals() ? "1" : "0") << "\n"
|
||||
<< "Catch FPE: " << (OSD::ToCatchFloatingSignals() ? "1" : "0") << "\n";
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
||||
Standard_Integer toSetSig = -1, toSetFpe = -1;
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
|
||||
{
|
||||
TCollection_AsciiString anArg (theArgVec[anArgIter]);
|
||||
anArg.LowerCase();
|
||||
if (anArg == "-fpe"
|
||||
&& toSetFpe == -1
|
||||
&& anArgIter + 1 < theArgNb)
|
||||
{
|
||||
TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
|
||||
if (anArgNext == "1")
|
||||
{
|
||||
toSetFpe = 1;
|
||||
}
|
||||
else if (anArgNext == "0")
|
||||
{
|
||||
toSetFpe = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (toSetSig == -1
|
||||
&& (anArg == "0" || anArg == "1"))
|
||||
{
|
||||
toSetSig = anArg == "1" ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (toSetSig == -1)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (toSetSig == 1
|
||||
&& toSetFpe == -1)
|
||||
{
|
||||
OSD_Environment aEnv ("CSF_FPE");
|
||||
TCollection_AsciiString aEnvStr = aEnv.Value();
|
||||
setFPE = (! aEnvStr.IsEmpty() && aEnvStr.Value(1) != '0');
|
||||
toSetFpe = (!aEnvStr.IsEmpty() && aEnvStr.Value(1) != '0') ? 1 : 0;
|
||||
}
|
||||
|
||||
OSD::SetSignal (toSetSig == 1, toSetFpe == 1);
|
||||
if (toSetSig == 1)
|
||||
{
|
||||
theDI << "Signal handlers are set, with FPE " << (toSetFpe == 1 ? "armed" : "disarmed");
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << "Signal handlers are reset to defaults, with FPE " << (toSetFpe == 1 ? "armed" : "disarmed");
|
||||
}
|
||||
OSD::SetSignal (setFPE);
|
||||
theDI << "Signal handlers are set, with FPE " << (setFPE ? "armed" : "disarmed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1052,7 +1102,7 @@ void Draw::BasicCommands(Draw_Interpretor& theCommands)
|
||||
__FILE__, dmeminfo, g);
|
||||
theCommands.Add("dperf","dperf [reset] -- show performance counters, reset if argument is provided",
|
||||
__FILE__,dperf,g);
|
||||
theCommands.Add("dsetsignal","dsetsignal [fpe=0] -- set OSD signal handler, with FPE option if argument is given",
|
||||
theCommands.Add("dsetsignal","dsetsignal {0|1} [-fpe {0|1}] -- set OSD signal handler, with FPE option if argument is given",
|
||||
__FILE__,dsetsignal,g);
|
||||
|
||||
theCommands.Add("dparallel",
|
||||
|
@@ -50,7 +50,9 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Return signal catching value previously set by SetSignal().
|
||||
Standard_EXPORT static Standard_Boolean ToCatchSignals();
|
||||
|
||||
//! Sets signal and exception handlers.
|
||||
//!
|
||||
//! ### Windows-specific notes
|
||||
@@ -102,12 +104,31 @@ public:
|
||||
//! ::throw() will be called) is regulated by the
|
||||
//! OCC_CONVERT_SIGNALS macro used during compilation of Open CASCADE and
|
||||
//! user's code. Refer to Foundation Classes User's Guide for further details.
|
||||
//!
|
||||
Standard_EXPORT static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True);
|
||||
Standard_EXPORT static void SetSignal (Standard_Boolean theToCatch,
|
||||
Standard_Boolean theFloatingSignal);
|
||||
|
||||
//! Sets signal and exception handlers.
|
||||
static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True)
|
||||
{
|
||||
SetSignal (Standard_True, theFloatingSignal);
|
||||
}
|
||||
|
||||
//! Initializes thread-local signal handlers.
|
||||
//! This method sets up extra handlers which are not inherited on creation of new thread.
|
||||
//! This includes _set_se_translator() on Windows platform and SetFloatingSignals().
|
||||
//! The main purpose of this method is initializing handlers for newly created threads
|
||||
//! without overriding global handlers (set by application or by OSD::SetSignal()).
|
||||
//! In most cases OSD::SetSignal() should be called instead.
|
||||
Standard_EXPORT static void SetThreadLocalSignal (Standard_Boolean theToCatch,
|
||||
Standard_Boolean theFloatingSignal);
|
||||
|
||||
//! Return floating signal catching value previously set by SetSignal().
|
||||
Standard_EXPORT static Standard_Boolean ToCatchFloatingSignals();
|
||||
|
||||
//! Enables/disables floating signal (FPE) catching for current thread.
|
||||
//! This call does NOT actually register any exception handler - SetSignal() should be called beforehand for complete setup.
|
||||
Standard_EXPORT static void SetFloatingSignals (Standard_Boolean theFloatingSignal);
|
||||
|
||||
//! Commands the process to sleep for a number of seconds.
|
||||
Standard_EXPORT static void SecSleep (const Standard_Integer aDelay);
|
||||
|
||||
|
@@ -310,7 +310,7 @@ void OSD_ThreadPool::performJob (Handle(Standard_Failure)& theFailure,
|
||||
// =======================================================================
|
||||
void OSD_ThreadPool::EnumeratedThread::performThread()
|
||||
{
|
||||
OSD::SetSignal (false);
|
||||
OSD::SetThreadLocalSignal (OSD::ToCatchSignals(), false);
|
||||
for (;;)
|
||||
{
|
||||
myWakeEvent.Wait();
|
||||
@@ -323,7 +323,7 @@ void OSD_ThreadPool::EnumeratedThread::performThread()
|
||||
myFailure.Nullify();
|
||||
if (myJob != NULL)
|
||||
{
|
||||
OSD::SetSignal (myToCatchFpe);
|
||||
OSD::SetThreadLocalSignal (OSD::ToCatchSignals(), myToCatchFpe);
|
||||
OSD_ThreadPool::performJob (myFailure, myJob, myThreadIndex);
|
||||
myJob = NULL;
|
||||
}
|
||||
|
@@ -17,8 +17,18 @@
|
||||
#include <Standard_DivideByZero.hxx>
|
||||
#include <Standard_Overflow.hxx>
|
||||
|
||||
static Standard_Boolean OSD_WasSetSignal = Standard_False;
|
||||
static Standard_THREADLOCAL Standard_Boolean fFltExceptions = Standard_False;
|
||||
|
||||
//=======================================================================
|
||||
//function : ToCatchSignals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean OSD::ToCatchSignals()
|
||||
{
|
||||
return OSD_WasSetSignal;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ToCatchFloatingSignals
|
||||
//purpose :
|
||||
@@ -367,13 +377,40 @@ static LONG WINAPI WntHandler (EXCEPTION_POINTERS *lpXP)
|
||||
lpXP->ExceptionRecord->ExceptionInformation[0]);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetFloatingSignals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OSD::SetFloatingSignals (Standard_Boolean theFloatingSignal)
|
||||
{
|
||||
fFltExceptions = theFloatingSignal;
|
||||
_controlfp (theFloatingSignal ? 0 : _OSD_FPX, _OSD_FPX);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetThreadLocalSignal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OSD::SetThreadLocalSignal (Standard_Boolean theToCatch,
|
||||
Standard_Boolean theFloatingSignal)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_set_se_translator (theToCatch ? TranslateSE : NULL);
|
||||
#else
|
||||
(void )theToCatch;
|
||||
#endif
|
||||
SetFloatingSignals (theFloatingSignal);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetSignal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
|
||||
void OSD::SetSignal (Standard_Boolean theToCatch,
|
||||
Standard_Boolean theFloatingSignal)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
|
||||
OSD_WasSetSignal = theToCatch;
|
||||
#if !defined(OCCT_UWP) || defined(NTDDI_WIN10_TH2)
|
||||
OSD_Environment env ("CSF_DEBUG_MODE");
|
||||
TCollection_AsciiString val = env.Value();
|
||||
@@ -391,37 +428,34 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
|
||||
// when user's code is compiled with /EHs
|
||||
// Replaces the existing top-level exception filter for all existing and all future threads
|
||||
// in the calling process
|
||||
::SetUnhandledExceptionFilter (/*(LPTOP_LEVEL_EXCEPTION_FILTER)*/ WntHandler);
|
||||
::SetUnhandledExceptionFilter (theToCatch ? WntHandler : NULL);
|
||||
#endif // NTDDI_WIN10_TH2
|
||||
|
||||
// Signal handlers will only be used when the method ::raise() will be used
|
||||
// Handlers must be set for every thread
|
||||
if (signal (SIGSEGV, (void(*)(int))SIGWntHandler) == SIG_ERR)
|
||||
void(*aHandler)(int) = theToCatch ? (void(*)(int))SIGWntHandler : (void(*)(int))SIG_DFL;
|
||||
if (signal (SIGSEGV, aHandler) == SIG_ERR)
|
||||
cout << "signal(OSD::SetSignal) error\n";
|
||||
if (signal (SIGFPE, (void(*)(int))SIGWntHandler) == SIG_ERR)
|
||||
if (signal (SIGFPE, aHandler) == SIG_ERR)
|
||||
cout << "signal(OSD::SetSignal) error\n";
|
||||
if (signal (SIGILL, (void(*)(int))SIGWntHandler) == SIG_ERR)
|
||||
if (signal (SIGILL, aHandler) == SIG_ERR)
|
||||
cout << "signal(OSD::SetSignal) error\n";
|
||||
|
||||
// Set Ctrl-C and Ctrl-Break handler
|
||||
fCtrlBrk = Standard_False;
|
||||
#ifndef OCCT_UWP
|
||||
SetConsoleCtrlHandler (&_osd_ctrl_break_handler, TRUE);
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
// _se_translator_function pOldSeFunc =
|
||||
_set_se_translator (TranslateSE);
|
||||
if (theToCatch)
|
||||
{
|
||||
SetConsoleCtrlHandler (&_osd_ctrl_break_handler, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetConsoleCtrlHandler (NULL, FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
fFltExceptions = theFloatingSignal;
|
||||
if (theFloatingSignal)
|
||||
{
|
||||
_controlfp (0, _OSD_FPX); // JR add :
|
||||
}
|
||||
else {
|
||||
_controlfp (_OSD_FPX, _OSD_FPX); // JR add :
|
||||
}
|
||||
} // end OSD :: SetSignal
|
||||
SetThreadLocalSignal (theToCatch, theFloatingSignal);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//==== ControlBreak
|
||||
@@ -874,55 +908,73 @@ static void SegvHandler(const int theSignal,
|
||||
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : SetFloatingSignals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OSD::SetFloatingSignals (Standard_Boolean theFloatingSignal)
|
||||
{
|
||||
fFltExceptions = theFloatingSignal;
|
||||
#if defined (__linux__)
|
||||
if (theFloatingSignal)
|
||||
{
|
||||
feenableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
fedisableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
|
||||
}
|
||||
#elif defined (sgi) || defined (IRIX)
|
||||
char* aTrapFpeEnv = getenv ("TRAP_FPE");
|
||||
if (aTrapFpeEnv == NULL)
|
||||
{
|
||||
#ifdef OCCT_DEBUG
|
||||
std::cout << "On SGI you must set TRAP_FPE environment variable :\n"
|
||||
"set env(TRAP_FPE) \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\" or\n"
|
||||
"setenv TRAP_FPE \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\"\n";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetThreadLocalSignal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OSD::SetThreadLocalSignal (Standard_Boolean theToCatch,
|
||||
Standard_Boolean theFloatingSignal)
|
||||
{
|
||||
(void )theToCatch;
|
||||
SetFloatingSignals (theFloatingSignal);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//==== SetSignal
|
||||
//==== Set the differents signals:
|
||||
//============================================================================
|
||||
|
||||
void OSD::SetSignal(const Standard_Boolean aFloatingSignal)
|
||||
void OSD::SetSignal (Standard_Boolean theToCatch,
|
||||
Standard_Boolean theFloatingSignal)
|
||||
{
|
||||
struct sigaction act, oact;
|
||||
int stat = 0;
|
||||
|
||||
if( aFloatingSignal ) {
|
||||
//==== Enable the floating point exceptions ===============
|
||||
OSD_WasSetSignal = theToCatch;
|
||||
SetFloatingSignals (theFloatingSignal);
|
||||
#if defined (__sun) || defined (SOLARIS)
|
||||
sigfpe_handler_type PHandler = (sigfpe_handler_type) Handler ;
|
||||
stat = ieee_handler("set", "invalid", PHandler);
|
||||
stat = ieee_handler("set", "division", PHandler) || stat;
|
||||
stat = ieee_handler("set", "overflow", PHandler) || stat;
|
||||
|
||||
//stat = ieee_handler("set", "underflow", PHandler) || stat;
|
||||
//stat = ieee_handler("set", "inexact", PHandler) || stat;
|
||||
|
||||
if (stat) {
|
||||
#ifdef OCCT_DEBUG
|
||||
cerr << "ieee_handler does not work !!! KO " << endl;
|
||||
#endif
|
||||
}
|
||||
#elif defined (__linux__)
|
||||
feenableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
|
||||
fFltExceptions = Standard_True;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
int aSunStat = 0;
|
||||
sigfpe_handler_type anFpeHandler = (theToCatch && theFloatingSignal) ? (sigfpe_handler_type )Handler : NULL;
|
||||
aSunStat = ieee_handler ("set", "invalid", anFpeHandler);
|
||||
aSunStat = ieee_handler ("set", "division", anFpeHandler) || aSunStat;
|
||||
aSunStat = ieee_handler ("set", "overflow", anFpeHandler) || aSunStat;
|
||||
//aSunStat = ieee_handler ("set", "underflow", anFpeHandler) || aSunStat;
|
||||
//aSunStat = ieee_handler ("set", "inexact", anFpeHandler) || aSunStat;
|
||||
if (aSunStat)
|
||||
{
|
||||
#if defined (__linux__)
|
||||
fedisableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
|
||||
fFltExceptions = Standard_False;
|
||||
#ifdef OCCT_DEBUG
|
||||
std::cerr << "ieee_handler does not work !!! KO\n";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (sgi) || defined (IRIX )
|
||||
char *TRAP_FPE = getenv("TRAP_FPE") ;
|
||||
if ( TRAP_FPE == NULL ) {
|
||||
#ifdef OCCT_DEBUG
|
||||
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 << "setenv TRAP_FPE \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\"" << endl ;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
struct sigaction act, oact;
|
||||
|
||||
//==== Save the old Signal Handler, and set the new one ===================
|
||||
|
||||
@@ -934,14 +986,21 @@ void OSD::SetSignal(const Standard_Boolean aFloatingSignal)
|
||||
act.sa_flags = 0 ;
|
||||
#endif
|
||||
#ifdef SA_SIGINFO
|
||||
act.sa_flags = act.sa_flags | SA_SIGINFO ;
|
||||
act.sa_sigaction = /*(void(*)(int, siginfo_t *, void*))*/ Handler;
|
||||
if (theToCatch)
|
||||
{
|
||||
act.sa_flags = act.sa_flags | SA_SIGINFO;
|
||||
act.sa_sigaction = Handler;
|
||||
}
|
||||
else
|
||||
{
|
||||
act.sa_handler = SIG_DFL;
|
||||
}
|
||||
#else
|
||||
act.sa_handler = /*(SIG_PFV)*/ Handler;
|
||||
act.sa_handler = theToCatch ? Handler : SIG_DFL;
|
||||
#endif
|
||||
|
||||
//==== Always detected the signal "SIGFPE" =================================
|
||||
stat = sigaction(SIGFPE,&act,&oact); // ...... floating point exception
|
||||
int stat = sigaction(SIGFPE,&act,&oact); // ...... floating point exception
|
||||
if (stat) {
|
||||
#ifdef OCCT_DEBUG
|
||||
cerr << "sigaction does not work !!! KO " << endl;
|
||||
@@ -1003,11 +1062,14 @@ void OSD::SetSignal(const Standard_Boolean aFloatingSignal)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef SA_SIGINFO
|
||||
act.sa_sigaction = /*(void(*)(int, siginfo_t *, void*))*/ SegvHandler;
|
||||
#else
|
||||
act.sa_handler = /*(SIG_PFV)*/ SegvHandler;
|
||||
#endif
|
||||
if (theToCatch)
|
||||
{
|
||||
#ifdef SA_SIGINFO
|
||||
act.sa_sigaction = /*(void(*)(int, siginfo_t *, void*))*/ SegvHandler;
|
||||
#else
|
||||
act.sa_handler = /*(SIG_PFV)*/ SegvHandler;
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( sigaction( SIGSEGV , &act , &oact ) ) // ...... segmentation violation
|
||||
perror("OSD::SetSignal sigaction( SIGSEGV , &act , &oact ) ") ;
|
||||
@@ -1027,7 +1089,6 @@ void OSD::SetSignal(const Standard_Boolean aFloatingSignal)
|
||||
exit (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
@@ -55,6 +55,7 @@
|
||||
#include <OSD_Exception_ACCESS_VIOLATION.hxx>
|
||||
#include <OSD_Exception_STACK_OVERFLOW.hxx>
|
||||
#include <OSD.hxx>
|
||||
#include <OSD_ThreadPool.hxx>
|
||||
#include <STEPCAFControl_Writer.hxx>
|
||||
#include <STEPControl_StepModelType.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
@@ -2458,6 +2459,68 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Auxiliary functor.
|
||||
struct TestParallelFunctor
|
||||
{
|
||||
TestParallelFunctor() : myNbNotRaised (0), myNbSigSegv (0), myNbUnknown (0) {}
|
||||
|
||||
Standard_Integer NbNotRaised() const { return myNbNotRaised; }
|
||||
Standard_Integer NbSigSegv() const { return myNbSigSegv; }
|
||||
Standard_Integer NbUnknown() const { return myNbUnknown; }
|
||||
|
||||
void operator() (int theThreadId, int theTaskId) const
|
||||
{
|
||||
(void )theThreadId;
|
||||
(void )theTaskId;
|
||||
|
||||
// Test Access Violation
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
int* pint = NULL;
|
||||
*pint = 4;
|
||||
Standard_Atomic_Increment (&myNbNotRaised);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
catch (OSD_Exception_ACCESS_VIOLATION const&)
|
||||
#else
|
||||
catch (OSD_SIGSEGV const&)
|
||||
#endif
|
||||
{
|
||||
Standard_Atomic_Increment (&myNbSigSegv);
|
||||
}
|
||||
catch (Standard_Failure const& )
|
||||
{
|
||||
Standard_Atomic_Increment (&myNbUnknown);
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
mutable volatile Standard_Integer myNbNotRaised;
|
||||
mutable volatile Standard_Integer myNbSigSegv;
|
||||
mutable volatile Standard_Integer myNbUnknown;
|
||||
};
|
||||
|
||||
static Standard_Integer OCC30775 (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** )
|
||||
{
|
||||
if (theNbArgs != 1)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(OSD_ThreadPool) aPool = new OSD_ThreadPool (4);
|
||||
OSD_ThreadPool::Launcher aLauncher (*aPool, 4);
|
||||
TestParallelFunctor aFunctor;
|
||||
aLauncher.Perform (0, 100, aFunctor);
|
||||
theDI << "NbRaised: " << (aFunctor.NbSigSegv() + aFunctor.NbUnknown()) << "\n"
|
||||
<< "NbNotRaised: " << aFunctor.NbNotRaised() << "\n"
|
||||
<< "NbSigSeg: " << aFunctor.NbSigSegv() << "\n"
|
||||
<< "NbUnknown: " << aFunctor.NbUnknown() << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma optimize( "", on )
|
||||
#endif
|
||||
@@ -4816,7 +4879,8 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
|
||||
theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
|
||||
theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
|
||||
theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
|
||||
theCommands.Add("OCC6143", "OCC6143", __FILE__, OCC6143, group);
|
||||
theCommands.Add("OCC6143", "OCC6143 catching signals", __FILE__, OCC6143, group);
|
||||
theCommands.Add("OCC30775", "OCC30775 catching signals in threads", __FILE__, OCC30775, group);
|
||||
theCommands.Add("OCC7141", "OCC7141 [nCount] aPath", __FILE__, OCC7141, group);
|
||||
theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
|
||||
theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);
|
||||
|
@@ -3,13 +3,13 @@
|
||||
pload QAcommands
|
||||
|
||||
# start with enabled signals
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
# first, disable
|
||||
dsetsignal 0
|
||||
dsetsignal 1 -fpe 0
|
||||
OCC28829
|
||||
|
||||
# then, enable
|
||||
puts "REQUIRED OCC28829 All: Standard_NumericError"
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
catch {OCC28829}
|
||||
|
23
tests/bugs/fclasses/bug30775
Normal file
23
tests/bugs/fclasses/bug30775
Normal file
@@ -0,0 +1,23 @@
|
||||
puts "================"
|
||||
puts "0030775: OSD::SetSignal() within OSD_ThreadPool should not override global handlers"
|
||||
puts "================"
|
||||
puts ""
|
||||
|
||||
pload QAcommands
|
||||
|
||||
dsetsignal 1 -fpe 1
|
||||
set IsDone [catch {set aResult [OCC30775]} result]
|
||||
|
||||
if { ${IsDone} != 0 } {
|
||||
puts "result = ${result}"
|
||||
puts "Faulty test case"
|
||||
} else {
|
||||
if { [string first "NbRaised: 100" $aResult] != -1 } {
|
||||
puts "OK test case"
|
||||
} else {
|
||||
puts "Faulty test case"
|
||||
}
|
||||
}
|
||||
|
||||
#dsetsignal 0 -fpe 0
|
||||
#set IsDone [catch {set aResult [OCC30775]} result]
|
@@ -15,9 +15,9 @@ pload QAcommands
|
||||
|
||||
set BugNumber OCC6143
|
||||
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
set IsDone [catch {set aResult [OCC6143]} result]
|
||||
dsetsignal
|
||||
dsetsignal 1 -fpe 0
|
||||
|
||||
if { ${IsDone} != 0 } {
|
||||
puts "result = ${result}"
|
||||
|
@@ -8,7 +8,7 @@ puts ""
|
||||
|
||||
set Tol 1.0e-7
|
||||
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
restore [locate_data_file bug28054_FaceProj.brep] f1
|
||||
restore [locate_data_file bug28054_EdgeProj.brep] e1
|
||||
|
@@ -9,7 +9,7 @@ puts ""
|
||||
|
||||
set Tol 1.0e-7
|
||||
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
cone c 0 0 0 45 0
|
||||
trimv c1 c 5 10
|
||||
|
@@ -6,7 +6,7 @@ puts ""
|
||||
# Incomplete result of section operation between attached shapes
|
||||
#######################################################################
|
||||
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
# Before the fix, section curve was incomplete
|
||||
|
||||
|
@@ -4,7 +4,7 @@ puts "============"
|
||||
puts ""
|
||||
|
||||
# enable FPE signals
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
restore [locate_data_file bug28085_object.brep] b1
|
||||
restore [locate_data_file bug28085_tool.brep] b2
|
||||
|
@@ -15,7 +15,7 @@ restore [locate_data_file bug26952_B41.brep] b1
|
||||
restore [locate_data_file bug26952_Tank41_1.brep] b2
|
||||
|
||||
# enable FPE signals
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
bclearobjects
|
||||
bcleartools
|
||||
@@ -25,7 +25,7 @@ bfillds
|
||||
bbop result 0
|
||||
|
||||
# disable FPE signals
|
||||
dsetsignal 0
|
||||
dsetsignal 1 -fpe 0
|
||||
|
||||
checkprops result -s 424.666
|
||||
checknbshapes result -wire 2 -face 1
|
||||
|
@@ -8,7 +8,7 @@ puts ""
|
||||
|
||||
# Set signals on.
|
||||
pload MODELING
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
# Prepare input data.
|
||||
restore [locate_data_file bug28175_2.brep] c
|
||||
|
@@ -11,7 +11,7 @@ box b 1 2 3
|
||||
vcaps -softMode 1
|
||||
|
||||
# disable FPE signals -- these often occur in software OpenGL drivers
|
||||
dsetsignal 0
|
||||
dsetsignal 1 -fpe 0
|
||||
|
||||
vclear
|
||||
vinit View1
|
||||
|
@@ -6,7 +6,7 @@ puts ""
|
||||
# Exception in intersection algorithm if FPE is switched on
|
||||
######################################################
|
||||
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
restore [locate_data_file bug27842_shape1_fix.brep] b1
|
||||
restore [locate_data_file bug27842_shape2_fix.brep] b2
|
||||
|
@@ -6,7 +6,7 @@ puts ""
|
||||
foreach a [directory c_*] {unset $a}
|
||||
|
||||
# enable FPE signals
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
restore [locate_data_file bug28883_Prism.brep] b1
|
||||
restore [locate_data_file bug28883_LES_2d_shell.brep] b2
|
||||
|
@@ -6,7 +6,7 @@ puts ""
|
||||
# Intersection of two cylinders fails
|
||||
#######################################################################
|
||||
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
set GoodNbCurv 4
|
||||
|
||||
|
@@ -6,7 +6,7 @@ puts ""
|
||||
# Intersection of two cylinders fails
|
||||
#######################################################################
|
||||
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
set GoodNbCurv 4
|
||||
|
||||
|
@@ -6,7 +6,7 @@ puts ""
|
||||
# Intersection of two cylinders fails
|
||||
#######################################################################
|
||||
|
||||
dsetsignal 1
|
||||
dsetsignal 1 -fpe 1
|
||||
|
||||
set GoodNbCurv 2
|
||||
|
||||
|
@@ -39,7 +39,7 @@ puts "1M random values, 18 significant digits, in range (-1e305, 1e305)"
|
||||
CheckAtof 1000000 16 -1e305 1e305
|
||||
|
||||
# Disarm FPE signals - otherwise they will be raised if signaling NAN appears
|
||||
dsetsignal 0
|
||||
dsetsignal 1 -fpe 0
|
||||
|
||||
puts "Special values + 1M values defined by random binary data, 10 digits"
|
||||
CheckAtof 1000000 10 0 0
|
||||
|
Reference in New Issue
Block a user