From: bangerth Date: Tue, 1 Aug 2006 19:46:06 +0000 (+0000) Subject: Don't abort a program any more if an exception is presently being handled. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5b393360698e1b46b8114cf6d05147296d37f18;p=dealii-svn.git Don't abort a program any more if an exception is presently being handled. git-svn-id: https://svn.dealii.org/trunk@13573 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/source/subscriptor.cc b/deal.II/base/source/subscriptor.cc index d164737244..37969bb997 100644 --- a/deal.II/base/source/subscriptor.cc +++ b/deal.II/base/source/subscriptor.cc @@ -73,10 +73,50 @@ Subscriptor::~Subscriptor () infostring += std::string("\n from Subscriber ") + std::string(it->first); } - - Assert (counter == 0, ExcInUse(counter, - object_info->name(), - infostring)); + + // if there are still active pointers, show + // a message and kill the program. However, + // under some circumstances, this is not so + // desirable. For example, in code like this + // + // Triangulation tria; + // DoFHandler *dh = new DoFHandler(tria); + // ...some function that throws an exception + // + // the exception will lead to the + // destruction of the triangulation, but + // since the dof_handler is on the heap it + // will not be destroyed. This will trigger + // an assertion in the triangulation. If we + // kill the program at this point, we will + // never be able to learn what caused the + // problem. In this situation, just display + // a message and continue the program. + if (counter != 0) + { + if (std::uncaught_exception() == false) + { + Assert (counter == 0, + ExcInUse (counter, object_info->name(), infostring)); + } + else + { + std::cerr << "---------------------------------------------------------" + << std::endl + << "An object pointed to by a SmartPointer is being destroyed." + << std::endl + << "Under normal circumstances, this would abort the program." + << std::endl + << "However, another exception is being processed at the" + << std::endl + << "moment, so the program will continue to run to allow" + << std::endl + << "this exception to be processed." + << std::endl + << "---------------------------------------------------------" + << std::endl; + } + } #endif } diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index a0fa92c332..2090901be2 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -343,6 +343,38 @@ inconvenience this causes.

base

    +
  1. Changed: When there is still a SmartPointer object + pointing to another object at the time it is destroyed, this would cause + the program to be aborted. However, there are cases where this is not + desirable, for example here: +

    +       
    +          void f() 
    +          {
    +	    Triangulation tria;
    +	    DoFHandler *dh = new DoFHandler(tria);
    +	    ...some function that throws an exception
    +          }
    +       
    +       
    + When the exception is thrown but not caught, the two local objects are + destroyed in reverse order of their construction, i.e. first the pointer + then the triangulation. However, only the pointer, not the + DoFHandler pointed to is destroyed, triggering the abort in + the triangulation since there is still the DoFHandler + object pointing to it at the time of destruction of the + triangulation. In such cases, one would not want to see the program + aborted, since then one would never learn about the actual exception + being thrown. +
    + The behavior of the Subscriptor class as therefore been + changed to not abort the program any more if an exception is being + handled at the moment. Rather, only an error message is shown on + std::cerr. +
    + (WB 2006/08/01) +

    +
  2. Fixed: The TableHandler::write_tex accidentally took a parameter of type std::ofstream instead of std::ostream @@ -352,31 +384,32 @@ inconvenience this causes. (WB 2006/07/28)

    -
  3. New: GeometryInfo offers several new functions, - is_inside_unit_cell with an epsilon parameter to specify allowable - offsets from the actual unit cell, distance_to_unit_cell returning the - infinity norm of the distance of a given point to the unit cell, and - project_to_unit_cell returning the projection of a point onto the unit - cell. Also, a new member vertex_to_face allow to determine to which - faces of a cell a vertex belongs. -
    - (Ralf B. Schulz 2006/05/10) -

    +
  4. New: GeometryInfo offers several new + functions, is_inside_unit_cell with an epsilon parameter to + specify allowable offsets from the actual unit cell, + distance_to_unit_cell returning the infinity norm of the + distance of a given point to the unit cell, and + project_to_unit_cell returning the projection of a point + onto the unit cell. Also, a new member vertex_to_face allow + to determine to which faces of a cell a vertex belongs. +
    + (Ralf B. Schulz 2006/05/10) +

  5. Improved: DataOutBase::OutputFormat has a new value none, writing no - output at all. This way, the writing of output files can be controlled more - easily from parameter files. -
    - (GK 2006/04/14) -

    + class="member">OutputFormat has a new value none, + writing no output at all. This way, the writing of output files can be + controlled more easily from parameter files. +
    + (GK 2006/04/14) +

  6. Improved: VectorSlice has new functions - begin() and end(), - returning the corresponding vector iterators. -
    - (GK 2006/03/31) -

    + begin() and end(), + returning the corresponding vector iterators. +
    + (GK 2006/03/31) +

  7. New: The various tensor classes can now effectively be reset to zero by simply writing t=0; as has long been allowed for