[Boost.Log1]: Bug in boost/log/detail/ts_posix.hpp

Hi, I know that version 1 of John's logging library was never accepted and is probably not wildly used anymore nevertheless I found a nasty bug in it. It's strange but even after applying valgrind I found initially not the reason (probably I just assumed John's code is OK and it's something else) and it took some time until I resolved it. OK, for all users of this lib here is the patch: boost/log/detail/ts_posix.hpp: @@ -51,7 +51,7 @@ mutex & operator = ( const mutex & Not_Implemented); mutex( const mutex & From); public: - mutex() : m_mutex() { + mutex() : m_mutex(), m_count(0) { pthread_mutexattr_t attr; int res = pthread_mutexattr_init(&attr); assert(res == 0); I haven't checked whether this occurs in version 2 as well. Jens

On Tue, 24 Jun 2008 16:37:56 +0200, Jens Seidel <jensseidel@users.sf.net> wrote:
[...]OK, for all users of this lib here is the patch:
boost/log/detail/ts_posix.hpp: @@ -51,7 +51,7 @@ mutex & operator = ( const mutex & Not_Implemented); mutex( const mutex & From); public: - mutex() : m_mutex() { + mutex() : m_mutex(), m_count(0) { pthread_mutexattr_t attr; int res = pthread_mutexattr_init(&attr); assert(res == 0);
I haven't checked whether this occurs in version 2 as well.
Checked it: m_count is not initialized in boost/logging/detail/ts/ts_posix.hpp in version 2 either. Boris

On Tue, Jun 24, 2008 at 09:49:47PM +0200, Boris wrote:
On Tue, 24 Jun 2008 16:37:56 +0200, Jens Seidel <jensseidel@users.sf.net> wrote:
[...]OK, for all users of this lib here is the patch:
boost/log/detail/ts_posix.hpp: @@ -51,7 +51,7 @@ mutex & operator = ( const mutex & Not_Implemented); mutex( const mutex & From); public: - mutex() : m_mutex() { + mutex() : m_mutex(), m_count(0) { pthread_mutexattr_t attr; int res = pthread_mutexattr_init(&attr); assert(res == 0);
I haven't checked whether this occurs in version 2 as well.
Checked it: m_count is not initialized in boost/logging/detail/ts/ts_posix.hpp in version 2 either.
Boris, you're right! Since it is still not fixed could someone please commit the initialisation? It's unlikely to cause an error this way ... Path: http://svn.boost.org/svn/boost/sandbox/logging PS: John, it would also great if you could evaluate BOOST_DISABLE_THREADS. I don't use threads (up to now) but have to link against libpthread (at least with g++ 4.1, other versions do not require it!?). Jens

Jens Seidel wrote:
On Tue, Jun 24, 2008 at 09:49:47PM +0200, Boris wrote:
On Tue, 24 Jun 2008 16:37:56 +0200, Jens Seidel <jensseidel@users.sf.net> wrote:
[...]OK, for all users of this lib here is the patch:
boost/log/detail/ts_posix.hpp: @@ -51,7 +51,7 @@ mutex & operator = ( const mutex & Not_Implemented); mutex( const mutex & From); public: - mutex() : m_mutex() { + mutex() : m_mutex(), m_count(0) { pthread_mutexattr_t attr; int res = pthread_mutexattr_init(&attr); assert(res == 0);
I haven't checked whether this occurs in version 2 as well.
Checked it: m_count is not initialized in boost/logging/detail/ts/ts_posix.hpp in version 2 either.
Yup, I copied it from there :)
Boris, you're right! Since it is still not fixed could someone please commit the initialisation? It's unlikely to cause an error this way ...
Path: http://svn.boost.org/svn/boost/sandbox/logging
PS: John, it would also great if you could evaluate BOOST_DISABLE_THREADS. I don't use threads (up to now) but have to link against libpthread (at least with g++ 4.1, other versions do not require it!?).
Yes I will ASAP - sorry, at this time I'm bugged with other stuff and I'm a bit unresponsive to emails. Best, John
Jens _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- http://John.Torjo.com -- C++ expert http://blog.torjo.com ... call me only if you want things done right
participants (3)
-
Boris
-
Jens Seidel
-
John Torjo