Subject: [Boost-bugs] [Boost C++ Libraries] #2391: interprocess_recursive_mutex doesn't work interprocess
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-10-07 20:29:39
#2391: interprocess_recursive_mutex doesn't work interprocess
----------------------------------------------------+-----------------------
Reporter: Sergey Samsonik <serge_98_at_[hidden]> | Owner: igaztanaga
Type: Bugs | Status: new
Milestone: Boost 1.37.0 | Component: interprocess
Version: Boost 1.35.0 | Severity: Showstopper
Keywords: interprocess fork pthread |
----------------------------------------------------+-----------------------
The recursive mutex tests current thread using
detail::get_current_thread_id(), which in turn uses pthread_self(). The
latter function returns thread id that unique in context of a process. (As
least in CentOS 4.6 'm using.) This results in threads from different
processes not being synchronized. Sometimes it results in asserts (in
debug build) or exceptions (in release).
Attached is a small shared memory test that uses fork() which led me to
finding the problem. Environment and test's output:
$ g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --disable-
libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)
[sergeys_at_sergeys-vm32 boosttest]$ g++ bug.cc -o bug -I
/mnt/builder/3rdParty/boost/v35.0/include -L
/mnt/builder/3rdParty/boost/v35.0/lib32 -l rt
$ uname -a
Linux sergeys-vm32 2.6.9-78.0.1.ELsmp #1 SMP Tue Aug 5 11:02:47 EDT 2008
i686 i686 i386 GNU/Linux
$ g++ bug.cc -o bug -I /mnt/builder/3rdParty/boost/v35.0/include -L
/mnt/builder/3rdParty/boost/v35.0/lib32 -l rt
$ ./bug
parent pthread_self -1208224064
child pthread_self -1208224064
bug:
/mnt/builder/3rdParty/boost/v35.0/include/boost/interprocess/sync/emulation/interprocess_recursive_mutex.hpp:97:
void boost::interprocess::interprocess_recursive_mutex::unlock():
Assertion `detail::equal_thread_id(detail::get_current_thread_id(),
m_nOwner)' failed.
Aborted
Done child
Please note, that when built on different system (CentOS 5), the test runs
without assertion. But the mutex still doesn't protext the code as
intended.
-- Ticket URL: <http://svn.boost.org/trac/boost/ticket/2391> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC