Archived

This topic is now archived and is closed to further replies.

Shannon Barber

COM Exception Handling

Recommended Posts

Shannon Barber    1681
I''m bumped into an odd error, and I can''t seem to figure out which rule I''m breaking. The problem is, esp gets set to 0xCCCCCCCC whenever an exception is caught. On the return code, a couple of register pops are performed the app crashes due to an access violation... This is the offending code, it''s called by Excel on start-up through the _IDTExtensibility2 interface if that makes a difference.
  
HRESULT OnStartUp(SAFEARRAY** custom)
	{
	HRESULT hr;
	try
		{
		//...

		//Added to test the exception handling code

		_com_issue_error(E_FAIL);
		}
	catch(const _com_error& error)
		{
		TRACE(error.ErrorMessage());
		return(error.Error());
		}
	catch(...)
		{
		TRACE("Unhandled Exception in LSD2XL Startup\n");
		}
	return(S_OK);
	}
  
Magmai Kai Holmlor - Not For Rent

Share this post


Link to post
Share on other sites
Void    126
Geez, that would be hard to tell. It could some pre condition in the Excel code which you did not met.

An access violation is usually dereferencing a invalid memory location(ie pointer)

Have you tried getting a stackwalk (Alt-7) in debugger?

Share this post


Link to post
Share on other sites
GayleSaver    122
Not sure it''s wise to use a C++ exception stack frame when potentially leaving C++''s bounds. Microsoft uses SEH to implement their handlers, and their C/C++ compiler is bizzare in other ways (Windows was NOT built with the standard MSVC run-time library). Although SEH is used to implement C++ EH on MSVC, the stack pointer has different values between the two, since catch(x) should translate to __except(CxxEHFilter(...)) with ... being some code I can''t recall right now. 0xcccccc is the compiler-assigned default value for stack variables.

Share this post


Link to post
Share on other sites