From: Guido Kanschat Date: Mon, 5 May 2008 22:26:09 +0000 (+0000) Subject: fix problems with segmentation fault in tests X-Git-Tag: v8.0.0~9189 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40d0f48d7e72fe7d11a20691cba22bee887d1e9b;p=dealii.git fix problems with segmentation fault in tests git-svn-id: https://svn.dealii.org/trunk@16030 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/source/subscriptor.cc b/deal.II/base/source/subscriptor.cc index 36369372f7..3ea93b90de 100644 --- a/deal.II/base/source/subscriptor.cc +++ b/deal.II/base/source/subscriptor.cc @@ -120,6 +120,11 @@ Subscriptor::~Subscriptor () << std::endl; } } + // In case we do not abort + // on error, this will tell + // do_unsubscribe below that the + // object is unused now. + counter = 0; #endif } @@ -160,12 +165,16 @@ void Subscriptor::do_unsubscribe (const char* id) const { #ifdef DEBUG Assert (counter>0, ExcNotUsed()); + // This is for the case that we do + // not abort after the exception + if (counter == 0) + return; + Threads::ThreadMutex::ScopedLock lock (subscription_lock); --counter; #if DEAL_USE_MT == 0 const char* name = (id != 0) ? id : unknown_subscriber; - map_iterator it = counter_map.find(name); Assert (it != counter_map.end(), ExcNoSubscriber(object_info->name(), name)); Assert (it->second > 0, ExcNoSubscriber(object_info->name(), name)); diff --git a/tests/base/reference.cc b/tests/base/reference.cc index 0e18087593..eb6eacd22c 100644 --- a/tests/base/reference.cc +++ b/tests/base/reference.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -23,7 +23,13 @@ #include #include #include +#include +#include +// Provide memory for objects of type T such that access to a deleted +// object does not cause a segmentation fault +std::vector memory(10000); +int next = 0; class Test : public Subscriptor { @@ -47,7 +53,8 @@ int main() if (true) { Test a("A"); - const Test b("B"); + const Test& b("B"); + SmartPointer r(&a, "Test R"); SmartPointer s(&a, "const Test S"); // SmartPointer t=&b; // this one should not work @@ -74,6 +81,9 @@ int main() r = &c; Test d("D"); r = &d; + // Destruction of "Test R" will + // cause a spurious ExcNotUsed + // here, since D was deleted first } } diff --git a/tests/base/reference/cmp/generic b/tests/base/reference/cmp/generic index 63bebc7caa..9850c9b96e 100644 --- a/tests/base/reference/cmp/generic +++ b/tests/base/reference/cmp/generic @@ -12,7 +12,6 @@ DEAL::Construct D DEAL::Destruct D DEAL::ExcInUse (counter, object_info->name(), infostring) DEAL::Destruct C -DEAL::ExcNoSubscriber(object_info->name(), name) -DEAL::ExcNoSubscriber(object_info->name(), name) +DEAL::ExcNotUsed() DEAL::Destruct B DEAL::Destruct A diff --git a/tests/base/reference/cmp/mips-sgi-irix6.5+MIPSpro7.4 b/tests/base/reference/cmp/mips-sgi-irix6.5+MIPSpro7.4 deleted file mode 100644 index f6cb28670f..0000000000 --- a/tests/base/reference/cmp/mips-sgi-irix6.5+MIPSpro7.4 +++ /dev/null @@ -1,16 +0,0 @@ - -DEAL::Construct A -DEAL::Construct B -DEAL::a mutable -DEAL::b const -DEAL::r mutable -DEAL::s const -DEAL::t mutable -DEAL::u const -DEAL::Construct C -DEAL::Construct D -DEAL::Destruct D -DEAL::ExcInUse(counter, object_info->name(), infostring) -DEAL::Destruct C -DEAL::Destruct B -DEAL::Destruct A