<h3>Specific improvements</h3>
<ol>
+<li> Fixed: If you pipe content into the deallog object and there
+is no end-line or flush after this content, and if a file stream
+is associated to this object, and if that happens at the end of
+the lifetime of the program, then the program would crash.
+This is now fixed.
+<br>
+(Timo Heister, Wolfgang Bangerth, 2012/09/17)
+
<li> Fixed: The use of TableHandler::set_precision affected not only the
precision with which elements of a table were printed, but also the
precision carried by the output stream after writing the table was
(*outstreams[id] != 0)
&&
(outstreams[id]->str().length() > 0))
- *this << std::endl;
+ {
+ // except the situation is
+ // not quite that simple. if
+ // this object is the
+ // 'deallog' object, then it
+ // is destroyed upon exit of
+ // the program. since it's
+ // defined in a shared
+ // library that depends on
+ // libstdc++.so, destruction
+ // happens before destruction
+ // of std::cout/cerr, but
+ // after all file variables
+ // defined in user programs
+ // have been destroyed. in
+ // other words, if we get
+ // here and the object being
+ // destroyed is 'deallog' and
+ // if 'deallog' is associated
+ // with a file stream, then
+ // we're in trouble: we'll
+ // try to write to a file
+ // that doesn't exist any
+ // more, and we're likely
+ // going to crash (this is
+ // tested by
+ // base/log_crash_01). rather
+ // than letting it come to
+ // this, print a message to
+ // the screen (note that we
+ // can't issue an assertion
+ // here either since Assert
+ // may want to write to
+ // 'deallog' itself, and
+ // AssertThrow will throw an
+ // exception that can't be
+ // caught)
+ if ((this == &deallog) && file)
+ std::cerr << ("You still have content that was written to 'deallog' "
+ "but not flushed to the screen or a file while the "
+ "program is being terminated. This would lead to a "
+ "segmentation fault. Make sure you flush the "
+ "content of the 'deallog' object using 'std::endl' "
+ "before the end of the program.")
+ << std::endl;
+ else
+ *this << std::endl;
+ }
}
if (old_cerr)
//---------------------------- logtest.cc ---------------------------
// $Id: logtest.cc 23710 2011-05-17 04:50:10Z bangerth $
-// Version: $Name$
+// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2012 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
int main()
{
+ deal_II_exceptions::disable_abort_on_exception ();
+
std::ofstream logfile("log_crash_01/output");
deallog.attach(logfile);
+ deallog << "OK" << std::endl;
+
deallog << "no newline here!";
}