This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch 3.6.x-rpm-debug in repository nx-libs. commit be06f2156b16006fc0cb01c08fe2b5b04c108d7b Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Dec 25 03:49:09 2017 +0100 nxcomp/src/Log.h: handle errors due to missing buffers more gracefully. This error is surprisingly easy to trigger, so we should make sure that the program does not crash. --- nxcomp/src/Log.h | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/nxcomp/src/Log.h b/nxcomp/src/Log.h index e6fb815..ab1807c 100644 --- a/nxcomp/src/Log.h +++ b/nxcomp/src/Log.h @@ -447,10 +447,19 @@ class NXLog { if ( synchronized() ) { - per_thread_data *pdt = get_data(); - assert (!pdt->buffer.empty ()); - (*pdt->buffer.top()) << F; - flush(); + /* Verbosely discard data if we don't have a buffer. */ + if (!(out.has_buffer())) + { + std::cerr << "WARNING: no buffer available! " + << "Internal state error!\n" << "Log hunk will be discarded!" << std::endl; + } + else + { + per_thread_data *pdt = get_data(); + assert (!pdt->buffer.empty ()); + (*pdt->buffer.top()) << F; + flush(); + } } else { @@ -532,16 +541,24 @@ NXLog& operator<<(NXLog& out, const T& value) { if ( out.synchronized() ) { - // In synchronized mode, we buffer data until a newline, std::flush, or the buffer - // gets full. Then we dump the whole thing at once to the output stream, synchronizing - // with a mutex. - NXLog::per_thread_data *pdt = out.get_data(); - assert (!pdt->buffer.empty ()); - (*pdt->buffer.top()) << value; - - if ( ss_length(pdt->buffer.top()) >= out.thread_buffer_size_ || has_newline(value) ) - out.flush(); + /* Verbosely discard data if we don't have a buffer. */ + if (!(out.has_buffer())) + { + std::cerr << "WARNING: no buffer available! " + << "Internal state error!\n" << "Log hunk will be discarded!" << std::endl; + } + else + { + // In synchronized mode, we buffer data until a newline, std::flush, or the buffer + // gets full. Then we dump the whole thing at once to the output stream, synchronizing + // with a mutex. + NXLog::per_thread_data *pdt = out.get_data(); + assert (!pdt->buffer.empty ()); + (*pdt->buffer.top()) << value; + if ( ss_length(pdt->buffer.top()) >= out.thread_buffer_size_ || has_newline(value) ) + out.flush(); + } } else { -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git