From: bangerth Date: Sat, 10 Feb 2007 04:10:00 +0000 (+0000) Subject: Fix a bug where we were happily using iterators into a list even though this list... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3b24ea3456852145ede1d255f8eb3a6aaa09d94;p=dealii-svn.git Fix a bug where we were happily using iterators into a list even though this list is having its elements erased. git-svn-id: https://svn.dealii.org/trunk@14458 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index 4a8dab545f..abc8b101b3 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -735,6 +735,17 @@ inconvenience this causes.

lac

    +
  1. Fixed: The SparseDirectMA27 class allows + to run the sparse direct solver as a separate program (the + detached_ma27 program) rather than as part of the current + program in order to be able to run several instances of it in parallel + during multithreaded computations. However, the destructor of the SparseDirectMA27 class had a bug that when using + this detached mode led to a segmentation fault. This is now fixed. +
    + (WB 2007/02/09) +

    +
  2. Improved: A simple print_formatted function has been added to SparseMatrixEZ.
    diff --git a/deal.II/lac/source/sparse_direct.cc b/deal.II/lac/source/sparse_direct.cc index 6c773a1dca..16eb37e0b6 100644 --- a/deal.II/lac/source/sparse_direct.cc +++ b/deal.II/lac/source/sparse_direct.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -362,10 +362,24 @@ namespace CommunicationsLog void remove_history (const pid_t &child_pid) { Threads::ThreadMutex::ScopedLock lock (list_access_lock); - for (std::list::iterator i=communication_log.begin(); - i!=communication_log.end(); ++i) - if (i->child_pid == child_pid) - communication_log.erase (i); + + // go through the list of records and + // delete those that correspond to the + // current pid. note that list::erase + // invalidates iterators, so we have to + // re-initialize them each time we move + // from one to the next + unsigned int index=0; + while (index < communication_log.size()) + { + std::list::iterator i = communication_log.begin(); + std::advance (i, index); + + if (i->child_pid == child_pid) + communication_log.erase (i); + else + ++index; + } } } @@ -548,11 +562,11 @@ SparseDirectMA27::~SparseDirectMA27() // next close down client Threads::ThreadMutex::ScopedLock lock (detached_mode_data->mutex); write (detached_mode_data->server_client_pipe[1], "7", 1); - + // then also delete data delete detached_mode_data; detached_mode_data = 0; - }; + } }