Opened 13 years ago

Closed 13 years ago

#3295 closed Bugs (invalid)

throwing exception / assert in destructor

Reported by: BDM <benoitdm@…> Owned by: Ion Gaztañaga
Milestone: Boost 1.40.0 Component: interprocess
Version: Boost 1.38.0 Severity: Problem
Keywords: exception assert destructor Cc:

Description

hello, there is, I think, a bad use of exception in the destructor of http://svn.boost.org/svn/boost/trunk/boost/interprocess/sync/posix/interprocess_mutex.hpp

I have learned a rule at school: "no exception must be thrown within a destructor" (also see https://www.securecoding.cert.org/confluence/display/cplusplus/ERR33-CPP.+Destructors+must+be+exception-safe or http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.3)

In the destructor of interprocess_mutex, an assert check for the good destruction of the posix mutex, if it fails, it throws an exception ... which is really bad in my case :) (even if I unlock the mutex just before the destructor call)

Regards, BDM.

Change History (1)

comment:1 by Ion Gaztañaga, 13 years ago

Resolution: invalid
Status: newclosed

An assertion is not an exception, and is only activated in debug mode to catch errors. It's not equivalent to throwing an exception. If the assertion fails, then you have a really severe bug in your program, showing that the object is corrupted.

Note: See TracTickets for help on using tickets.