No error handler in destructor - what happens 
Author Message
 No error handler in destructor - what happens

I have some managed wrappers around some legacy C++ code.

So far in these managed wrappers, I have no error handling
code.  I have a couple of questions related to this:

(1) My understanding with .NET is that the garbage
collection is going to happen at an undetermined time, at
which point the destructor (aka Finalize) of the managed
C++ objects will be called.   If an error occurs while
processing the destructor, what will happen?  Will the
application just outright crash, or will it be propagated
up in some manner?

I have some bizarre bugs in my C# application which uses
these managed classes, and I'm trying to determine if they
may be related to errors in destructors.  When the error
occurs, I don't get anything realistic on the call stack
which generated the error.

When the destructors are called, are they supposed to be
on the call stack?

What is the preferred strategy for error handling in
destructors of managed C++ wrappers?

Thank you for any help out there.

Jeff Ulrich



Mon, 18 Jul 2005 23:45:27 GMT  
 No error handler in destructor - what happens
Quote:
> If an error occurs while processing the destructor, what will happen?

It can cause a call to terminate().  Do not allow errors to be thrown from a destructor.
Quote:

> I have some managed wrappers around some legacy C++ code.

> So far in these managed wrappers, I have no error handling
> code.  I have a couple of questions related to this:

> (1) My understanding with .NET is that the garbage
> collection is going to happen at an undetermined time, at
> which point the destructor (aka Finalize) of the managed
> C++ objects will be called.   If an error occurs while
> processing the destructor, what will happen?  Will the
> application just outright crash, or will it be propagated
> up in some manner?

> I have some bizarre bugs in my C# application which uses
> these managed classes, and I'm trying to determine if they
> may be related to errors in destructors.  When the error
> occurs, I don't get anything realistic on the call stack
> which generated the error.

> When the destructors are called, are they supposed to be
> on the call stack?

> What is the preferred strategy for error handling in
> destructors of managed C++ wrappers?

> Thank you for any help out there.

> Jeff Ulrich



Tue, 19 Jul 2005 00:21:29 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Incorrect/insufficiently precise compiler error for a malformed call to a destructor

2. Debug Error when calling a destructor from a class that's in a DLL

3. Error in destructor

4. destructor of exported class causes a debug error

5. pure virtual destructor causes linker error

6. Linker error with template class: No constructor/destructor

7. Memory check error on Map destructor

8. Tracing of where an error happens in code

9. Tracing of where an error happens in code

10. Error in COM+ that didn't happen in MTS

11. What happened to my errors?

12. Tracing of where an error happens in code

 

 
Powered by phpBB® Forum Software