Re: COM sometimes turns exceptions into HRESULTs, sometimes doesn't - why?



Hello Aaron,

threadproc
try
create object
call object.method
cause an access violation
catch
log error

Hmm... Are you relying on try/catch for catching structured exceptions (like Access Violation)?
There's a project-wide setting to enable this behavior, called /EHa, if I recall correctly.


This is sometimes frowned upon because it extends the original meaning of catch(...), which was "catch any *C++* exception that may be thrown", and structured exceptions are not C++ exceptions. That, and because it loses all information about the error condition -- all you have left is "something broke!".

Well that's a good question ... basically there are multiple DLLs
implementing a common interface, loaded at runtime depending on
configuration. It could have done with exported C++ classes as well, I
guess (or even a C API). Someone got carried away with COM.

Yeah, COM has all the infrastructure finished, so I can see why that choice was made. Exceptions are still verboten, though.


--
Best regards,
Kim Gräsman


.



Relevant Pages

  • Re: C# Exceptions
    ... Are the other exceptions like Null Reference or Invalid Operation ... Can they be converted to an Access Violation? ... that was able to launch a man in the middle attack could exploit the ... Cenzic Hailstorm finds vulnerabilities fast. ...
    (Pen-Test)
  • Re: COM sometimes turns exceptions into HRESULTs, sometimes doesnt - why?
    ... The proxy/stub pair must try and handle exceptions, so as not to tear down the mechanisms for marshalling, which may run on a secondary thread. ... If your COM object is constrained to be used from C++, and only from the same thread (strictly speaking, apartment) in the same process, I wonder why you went to the trouble of making it a COM object in the first place. ...
    (microsoft.public.win32.programmer.ole)
  • Re: Debugging VC6 DLL with a Delphi application
    ... If Delphi handles exceptions in DLLs, ... "Access violation" and "Stop always". ... Note that it can cause the debugger to stop often, ... It is also possible that Delphi has a setting that asks it to pass exceptions ...
    (microsoft.public.vc.debugger)