[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#956114: marked as done (dbus-c++: deadlock on timeout expiration)



Your message dated Thu, 23 Feb 2023 15:04:08 +0000
with message-id <E1pVD8i-001ffq-GW@fasolo.debian.org>
and subject line Bug#956114: fixed in dbus-c++ 0.9.0-11
has caused the Debian Bug report #956114,
regarding dbus-c++: deadlock on timeout expiration
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
956114: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=956114
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---

Package: libdbus-c++-1-0v5

Version: 0.9.0-8+b1

Tags: upstream patch

Severity: normal

 

Dear Maintainer,

 

Sometimes I'm getting a deadlock in dbus-c++ while debugging my application under gdb.

 

It happens when I interrupt the program when DBus request is already sent, but no reply received yet.

Then I'm debugging something for 25+ sec (so dbus timeout expires), continue execution and get a deadlock in a dbus-c++ dispatcher thread.

It happens for me only during gdb sessions. If I delay the reply on a DBus server side, different branch of logic is used by DBus and deadlock doesn't occur.

 

Backtrace of the deadlock:

 

(gdb) thread 4

[Switching to thread 4 (Thread 0xab721b40 (LWP 20192))]

#0  0xb7fd9d39 in __kernel_vsyscall ()

(gdb) bt

#0  0xb7fd9d39 in __kernel_vsyscall ()

#1  0xb3e0bde2 in __lll_lock_wait () from /lib/i386-linux-gnu/libpthread.so.0

#2  0xb3e0592e in pthread_mutex_lock () from /lib/i386-linux-gnu/libpthread.so.0

#3  0xb72917c8 in DBus::DefaultMutex::lock (this=0x5deb2d2c) at eventloop.cpp:104

#4  0xb7291c8a in DBus::DefaultTimeout::~DefaultTimeout (this=0x7a74a9e8, __in_chrg=<optimized out>) at eventloop.cpp:59

#5  0xb72933ce in DBus::BusTimeout::~BusTimeout (this=0x7a74a9e0, __in_chrg=<optimized out>) at ../include/dbus-c++/eventloop-integration.h:44

#6  DBus::BusTimeout::~BusTimeout (this=0x7a74a9e0, __in_chrg=<optimized out>) at ../include/dbus-c++/eventloop-integration.h:44

#7  0xb724dc43 in _dbus_timeout_list_remove_timeout (timeout_list=0x5df1b710, timeout=0x7a73e170) at ../../../dbus/dbus-timeout.c:347

#8  0xb723814a in protected_change_timeout (enabled=0, toggle_function=0x0, remove_function=<optimized out>, add_function=0x0, timeout=<optimized out>, connection=0x5df1cef8) at ../../../dbus/dbus-connection.c:841

#9  _dbus_connection_remove_timeout_unlocked (timeout=<optimized out>, connection=0x5df1cef8) at ../../../dbus/dbus-connection.c:888

#10 reply_handler_timeout (data="" at ../../../dbus/dbus-connection.c:3344

#11 0xb7290bbb in DBus::Timeout::handle (this=0x7a74a9e0) at dispatcher.cpp:58

#12 0xb729288d in DBus::BusDispatcher::timeout_expired (this=0x5deb2ce0, et=...) at eventloop-integration.cpp:201

#13 0xb7291b52 in DBus::Slot<void, DBus::DefaultTimeout&>::operator() (param=..., this=<optimized out>) at ../include/dbus-c++/util.h:240

#14 DBus::DefaultMainLoop::dispatch (this=0x5deb2d20) at eventloop.cpp:221

#15 0xb7292610 in DBus::BusDispatcher::enter (this=0x5deb2ce0) at eventloop-integration.cpp:100

...

 

DBus requests are sent from another thread, but it is not participating in the deadlock.

 

Deadlock happens in a dispatcher thread itself, which tries to lock the same non-recursive mutex it already holds: DefaultMainLoop::_mutex_t.

 

Deadlock happens in DBus::DefaultMainLoop::dispatch() in the following code:

  _mutex_t.lock();

 

  ti = _timeouts.begin();

 

  while (ti != _timeouts.end())

  {

    DefaultTimeouts::iterator tmp = ti;

    ++tmp;

 

    if ((*ti)->enabled() && now_millis >= (*ti)->_expiration)

    {

      (*ti)->expired(*(*ti));

 

      if ((*ti)->_repeat)

      {

        (*ti)->_expiration = now_millis + (*ti)->_interval;

      }

 

    }

 

    ti = tmp;

  }

 

  _mutex_t.unlock();

 

It locks _mutex_t, then calls "(ti)->expired((*ti));" which just deletes the timeout,

and tries to lock _mutex_t again in DefaultTimeout destructor:

DefaultTimeout::~DefaultTimeout()

{

  _disp->_mutex_t.lock();

  _disp->_timeouts.remove(this);

  _disp->_mutex_t.unlock();

}

 

It results in a deadlock by one thread on a non-recursive mutex.

Exactly the same problem is also described here: https://sourceforge.net/p/dbus-cplusplus/mailman/message/28745127/

 

I've tried making DefaultMainLoop::_mutex_t recursive, and it fixed the problem.

 

Can you please apply this patch?

 

Patch:

 

--- eventloop.cpp   2020-04-06 12:26:06.902743512 +0300

+++ NEW_eventloop.cpp   2020-04-06 12:26:00.838743134 +0300

@@ -110,6 +110,7 @@

}

 

DefaultMainLoop::DefaultMainLoop() :

+  _mutex_t(true),

   _mutex_w(true)

{

}

 

 

-- System Information:

Debian Release: 9.12

  APT prefers oldstable

  APT policy: (500, 'oldstable')

Architecture: i386 (i686)

 

Kernel: Linux 4.19.0-0.bpo.6-686-pae (SMP w/2 CPU cores)

Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968), LANGUAGE=C (charmap=ANSI_X3.4-1968)

Shell: /bin/sh linked to /bin/dash

Init: systemd (via /run/systemd/system)

 

Versions of packages libdbus-c++-1-0v5 depends on:

ii  libc6         2.24-11+deb9u4

ii  libdbus-1-3   1.10.28-0+deb9u1

ii  libecore1     1.8.6-2.5+b2

ii  libgcc1       1:6.3.0-18+deb9u1

ii  libglib2.0-0  2.50.3-2+deb9u2

ii  libstdc++6    6.3.0-18+deb9u1

 

libdbus-c++-1-0v5 recommends no packages.

 

libdbus-c++-1-0v5 suggests no packages.

 

-- no debconf information


--- End Message ---
--- Begin Message ---
Source: dbus-c++
Source-Version: 0.9.0-11
Done: Thomas Uhle <uhle@cpan.org>

We believe that the bug you reported is fixed in the latest version of
dbus-c++, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 956114@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Thomas Uhle <uhle@cpan.org> (supplier of updated dbus-c++ package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Wed, 22 Feb 2023 22:55:50 +0100
Source: dbus-c++
Architecture: source
Version: 0.9.0-11
Distribution: unstable
Urgency: medium
Maintainer: Debian QA Group <packages@qa.debian.org>
Changed-By: Thomas Uhle <uhle@cpan.org>
Closes: 889114 956114 1018771
Changes:
 dbus-c++ (0.9.0-11) unstable; urgency=medium
 .
   * QA upload.
   * Add 09_fix_build_order_and_linking.patch to change the order in which the
     libraries are built and to fix the underlinking issue. (Closes: #889114)
   * Add 10_prevent_deadlock_on_timeout_expiration.patch to prevent a possible
     deadlock. (Closes: #956114)
   * Add 11_fix_MessageIter__copy_data.patch to fix copying nested types in
     dicts and structs. (LP: #1098723)
   * Add 12_autoconf_update.patch to avoid hard-to-read deprecation warnings
     that clutter the build logs.
   * Update 01_host_name_max.patch because stdio.h is needed by perror().
   * debian/control:
     + Add libdbus-1-dev to libdbus-c++-dev's dependencies. (Closes: #1018771)
     + Fix spelling and capitalization of the package descriptions.
     + Update Homepage to use https URL.
     + Mark libdbus-c++-bin as Multi-Arch: allowed. It fixes a regression since
       version 0.9.0-9.
     + Add Rules-Requires-Root: no.
     + Bump Standards-Version to 4.6.2, no changes needed.
   * debian/copyright:
     + Add Upstream-Contact, information copied from configure.ac.
     + Update packaging copyright according to debian/changelog and
       debian/patches.
   * debian/watch: Use uscan version 4.
   * Add debian/upstream/metadata.
Checksums-Sha1:
 e039991a21fc3fcaa7fb8864792e0634ddc20b50 2075 dbus-c++_0.9.0-11.dsc
 00db62549ae2275f2361ef64eec4e98ab94ccc06 11512 dbus-c++_0.9.0-11.debian.tar.xz
 679d90401ef60dcf37b164910b2420ac32da3766 7893 dbus-c++_0.9.0-11_source.buildinfo
Checksums-Sha256:
 30625fdc41d90b5fe76aec525355acc5aa1d81dc457e10cbfd0eef93654cf66c 2075 dbus-c++_0.9.0-11.dsc
 c91180507e5fd582726779de9f485ada84b1fe5e8cd8b7e84149a78f0f7c7c90 11512 dbus-c++_0.9.0-11.debian.tar.xz
 e16f7fd1a273db8ef69c5618e58d31f843f0c66b56b2734256849e6118aa004d 7893 dbus-c++_0.9.0-11_source.buildinfo
Files:
 380ba001f42082938d17f3c2712bf741 2075 libs optional dbus-c++_0.9.0-11.dsc
 268a8ba78c5c625197088707d6438cce 11512 libs optional dbus-c++_0.9.0-11.debian.tar.xz
 b12eafc36b4206d64f5634870e865347 7893 libs optional dbus-c++_0.9.0-11_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQHEBAEBCgAuFiEEQGIgyLhVKAI3jM5BH1x6i0VWQxQFAmP3fFkQHGJhZ2VAZGVi
aWFuLm9yZwAKCRAfXHqLRVZDFOCSC/46/TGZTa3mCFScaq+H9+xnb/xQaJn4s4Cb
dYgYtBLzhMOt0NeSyr/+1cMVVe5agnW2Kq5LXZxTQcMkJacK/Jfm1FuOKWw2yAMv
+NJt4+290QzYy3l64dXmAWu2//0kflrpyB8Kq29zTuMJN2JrkANaGO5JOq2mumnC
412XLy3wBmEjD6tjEhFPnQAxKnkBefrtPEXEP+/f+LRmrm2qoOrzft7OHnaXLPMQ
Nzb70sFZzYOMxthilU/wHa8Hq60LSmu5sDBBDpj0X9MoOWgtcOQ4Q2zRFYqN0Wqj
FL5jxXQ3Ji5v2rfnDai70qi4IX8jkefuVEl2nSfRaZLZ0iUIKJi+g/oZ3Nd8MhkB
kAeQOcp7Jqt1wm8+R/qbCDDNbtNHam6LVZ34OGynjL8kkEQqnsqAeGmjSlEmTSUW
100CgeB6N7kEq0XZ7oEwi7NtluXvA8PxuhzT1WUnjK8h7FX7HyrdC/UMfCOz8Qmo
jfCavxBnQ+awalZc/NSK2twAFjWxeTw=
=f+Rj
-----END PGP SIGNATURE-----

--- End Message ---

Reply to: