diff options
author | sma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-09-16 08:27:25 +0000 |
---|---|---|
committer | sma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-09-16 08:27:25 +0000 |
commit | 8cbe8b289f2a40b15a6404e4addc65f6c021c264 (patch) | |
tree | 2dea6f11ac71215af7ae8870b300db1770a79c3f | |
parent | cf7d78029433f0f912a8e90925d5241fd244c8c9 (diff) | |
download | ATCD-8cbe8b289f2a40b15a6404e4addc65f6c021c264.tar.gz |
ChangeLogTag: Tue Sep 16 08:27:00 UTC 2008 Simon Massey <sma@prismtech.com>
-rw-r--r-- | ACE/ChangeLog | 30 | ||||
-rw-r--r-- | ACE/ace/Object_Manager.cpp | 64 |
2 files changed, 94 insertions, 0 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index ab804682829..56293eb7dbb 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,33 @@ +Tue Sep 16 08:27:00 UTC 2008 Simon Massey <sma@prismtech.com> + + * ace/Object_Manager.cpp + + The following fixes stop our automated scoreboard from locking up during + automated window VC8 builds and test runs. The enhance the original + ACE_DISABLE_WIN32_ERROR_WINDOWS builds but only on VC8 and above INTEL + machines. + + Starting with VC8 (VS2005), it is necessary to add the call to + _set_abort_behavior( 0, _CALL_REPORTFAULT); to ensure that calls to + abort() do not bypass any declared unhandled exception handler and directly + call the default debugger or "report this problem to microsoft" dialogue. + This does NOT stop the standard message from being logged to the error stream. + + Also starting with VC8 (VS2005), Microsoft changed the behaviour of the CRT + in some security related and special situations. The are many situations in + which our ACE_UnhandledExceptionFilter will never be called. This is a major + change to the previous versions of the CRT and is not very well documented. + See: + http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101337 + + Basically the CRT simply uninstalls the registered unhandled exception filter + and then forces a call to the default-debugger. Jochen's solution is to stop + the CRT from calling SetUnhandledExceptionFilter() after we have setup our own + handler. NOTE this fix only works for intel based windows builds. + + This fix was derived from that proposed by Jochen Kalmbach here: + http://blog.kalmbachnet.de/?postid=75 + Tue Sep 16 08:12:00 UTC 2008 Simon Massey <sma@prismtech.com> * bin/diff-builds-and-group-fixed-tests-only.sh diff --git a/ACE/ace/Object_Manager.cpp b/ACE/ace/Object_Manager.cpp index 6a56de6db8a..43b74703120 100644 --- a/ACE/ace/Object_Manager.cpp +++ b/ACE/ace/Object_Manager.cpp @@ -30,6 +30,11 @@ #include "ace/Null_Mutex.h" #include "ace/Mutex.h" #include "ace/RW_Thread_Mutex.h" +#if defined (ACE_DISABLE_WIN32_ERROR_WINDOWS) && \ + defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) \ + && (_MSC_VER >= 1400) // VC++ 8.0 and above. + #include "ace/OS_NS_stdlib.h" +#endif // ACE_DISABLE_WIN32_ERROR_WINDOWS && ACE_WIN32 && !ACE_HAS_WINCE && (_MSC_VER >= 1400) ACE_RCSID(ace, Object_Manager, "$Id$") @@ -51,6 +56,18 @@ ACE_RCSID(ace, Object_Manager, "$Id$") ACE_BEGIN_VERSIONED_NAMESPACE_DECL +// Note the following fix was derived from that proposed by Jochen Kalmbach +// http://blog.kalmbachnet.de/?postid=75 +#if defined (ACE_DISABLE_WIN32_ERROR_WINDOWS) && \ + defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && \ + (_MSC_VER >= 1400) && defined (_M_IX86) +LPTOP_LEVEL_EXCEPTION_FILTER WINAPI ACEdisableSetUnhandledExceptionFilter ( + LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) +{ + return 0; +} +#endif // ACE_DISABLE_WIN32_ERROR_WINDOWS && ACE_WIN32 && !ACE_HAS_WINCE && (_MSC_VER >= 1400) && _M_IX86 + // Singleton pointer. ACE_Object_Manager *ACE_Object_Manager::instance_ = 0; @@ -257,6 +274,53 @@ ACE_Object_Manager::init (void) // And this will catch all unhandled exceptions. SetUnhandledExceptionFilter (&ACE_UnhandledExceptionFilter); + +# if (_MSC_VER >= 1400) // VC++ 8.0 and above. + // And this will stop the abort system call from being treated as a crash + _set_abort_behavior( 0, _CALL_REPORTFAULT); + + // Note the following fix was derived from that proposed by Jochen Kalmbach + // http://blog.kalmbachnet.de/?postid=75 + // See also: + // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101337 + // + // Starting with VC8 (VS2005), Microsoft changed the behaviour of the CRT in some + // security related and special situations. The are many situations in which our + // ACE_UnhandledExceptionFilter will never be called. This is a major change to + // the previous versions of the CRT and is not very well documented. + // The CRT simply forces the call to the default-debugger without informing the + // registered unhandled exception filter. Jochen's solution is to stop the CRT + // from calling SetUnhandledExceptionFilter() after we have done so above. + // NOTE this only works for intel based windows builds. + +# ifdef _M_IX86 + HMODULE hKernel32 = LoadLibrary (ACE_TEXT ("kernel32.dll")); + if (hKernel32) + { + void *pOrgEntry = + GetProcAddress (hKernel32, "SetUnhandledExceptionFilter"); + if (pOrgEntry) + { + unsigned char newJump[ 100 ]; + DWORD dwOrgEntryAddr = reinterpret_cast<DWORD> (pOrgEntry); + dwOrgEntryAddr += 5; // add 5 for 5 op-codes for jmp far + void *pNewFunc = &ACEdisableSetUnhandledExceptionFilter; + DWORD dwNewEntryAddr = reinterpret_cast<DWORD> (pNewFunc); + DWORD dwRelativeAddr = dwNewEntryAddr - dwOrgEntryAddr; + + newJump[ 0 ] = 0xE9; // JMP absolute + ACE_OS::memcpy (&newJump[ 1 ], &dwRelativeAddr, sizeof (pNewFunc)); + SIZE_T bytesWritten; + WriteProcessMemory ( + GetCurrentProcess (), + pOrgEntry, + newJump, + sizeof (pNewFunc) + 1, + &bytesWritten); + } + } +# endif // _M_IX86 +# endif // (_MSC_VER >= 1400) // VC++ 8.0 and above. #endif /* ACE_DISABLE_WIN32_ERROR_WINDOWS && ACE_WIN32 && !ACE_HAS_WINCE */ |