[jitsi-dev] XMPP deadlock on disconnect


#1

Hey

I think this happened after leaving standby, but I'm not sure. It probably
happens because Jitsi and Smack both detect that the connection was lost
during standby and want to disconnect. Could eventually be solved by
ignoring the disconnect event from Smack iif we already disconnecting by
ourself.

Regards,
Ingo

Found one Java-level deadlock:

···

=============================
"Thread-3935":
  waiting to lock monitor 0x2542e8dc (object 0x15047760, a
java.lang.Object),
  which is held by "Thread-3327"
"Thread-3327":
  waiting to lock monitor 0x06922b54 (object 0x164368b0, a
org.jivesoftware.smack.XMPPConnection),
  which is held by "Smack Packet Reader (40)"
"Smack Packet Reader (40)":
  waiting to lock monitor 0x2542e8dc (object 0x15047760, a
java.lang.Object),
  which is held by "Thread-3327"

Java stack information for the threads listed above:

"Thread-3935":
  at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.unregister(ProtocolProviderServiceJabberImpl.java:1377)
  - waiting to lock <0x15047760> (a java.lang.Object)
  at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.unregister(ProtocolProviderServiceJabberImpl.java:1366)
  at
net.java.sip.communicator.impl.gui.main.login.LoginManager$UnregisterProvide
r.run(LoginManager.java:596)
"Thread-3327":
  at
org.jivesoftware.smack.XMPPConnection.disconnect(XMPPConnection.java:440)
  - waiting to lock <0x164368b0> (a
org.jivesoftware.smack.XMPPConnection)
  at org.jivesoftware.smack.Connection.disconnect(Connection.java:459)
  at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.disconnectAndCleanConnection(ProtocolProviderServiceJabberImpl.java:133
1)
  at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.connectAndLogin(ProtocolProviderServiceJabberImpl.java:886)
  at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.connectAndLogin(ProtocolProviderServiceJabberImpl.java:714)
  - locked <0x15047760> (a java.lang.Object)
  at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.register(ProtocolProviderServiceJabberImpl.java:437)
  at
net.java.sip.communicator.plugin.reconnectplugin.ReconnectPluginActivator$Re
connectTask.run(ReconnectPluginActivator.java:876)
  at java.lang.Thread.run(Unknown Source)
"Smack Packet Reader (40)":
  at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.unregister(ProtocolProviderServiceJabberImpl.java:1377)
  - waiting to lock <0x15047760> (a java.lang.Object)
  at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl$JabberConnectionListener.connectionClosed(ProtocolProviderServiceJabber
Impl.java:1950)
  at
org.jivesoftware.smack.PacketReader.shutdown(PacketReader.java:134)
  at
org.jivesoftware.smack.XMPPConnection.shutdown(XMPPConnection.java:402)
  at
org.jivesoftware.smack.XMPPConnection.disconnect(XMPPConnection.java:444)
  - locked <0x164368b0> (a org.jivesoftware.smack.XMPPConnection)
  at org.jivesoftware.smack.Connection.disconnect(Connection.java:459)
  at
org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:322)
  at
org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
  at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

Found 1 deadlock.


#2

Hey Ingo,

thanks for the report. I recently found a situation where if the link
to the server is broken, a not cleaned connection will stay, which
will be registered, but not connected and not working. Well as I'm
writing this I realize that the ping mechanism should detect this, or
maybe will detect it, I will check that right now.
As I see the problem comes that there are two locks and
connecitonClosed is called from XmppConnection.disconnect and from it
we again call disconnect, although its already disconnected :slight_smile: Anyway
I was thinking of applying this patch to fix it. WDYT?

Thanks
damencho

jabber-lock_patch.patch (1.72 KB)

···

On Mon, Apr 9, 2012 at 3:10 PM, Ingo Bauersachs <ingo@jitsi.org> wrote:

Hey

I think this happened after leaving standby, but I'm not sure. It probably
happens because Jitsi and Smack both detect that the connection was lost
during standby and want to disconnect. Could eventually be solved by
ignoring the disconnect event from Smack iif we already disconnecting by
ourself.

Regards,
Ingo

Found one Java-level deadlock:

"Thread-3935":
waiting to lock monitor 0x2542e8dc (object 0x15047760, a
java.lang.Object),
which is held by "Thread-3327"
"Thread-3327":
waiting to lock monitor 0x06922b54 (object 0x164368b0, a
org.jivesoftware.smack.XMPPConnection),
which is held by "Smack Packet Reader (40)"
"Smack Packet Reader (40)":
waiting to lock monitor 0x2542e8dc (object 0x15047760, a
java.lang.Object),
which is held by "Thread-3327"

Java stack information for the threads listed above:

"Thread-3935":
at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.unregister(ProtocolProviderServiceJabberImpl.java:1377)
- waiting to lock <0x15047760> (a java.lang.Object)
at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.unregister(ProtocolProviderServiceJabberImpl.java:1366)
at
net.java.sip.communicator.impl.gui.main.login.LoginManager$UnregisterProvide
r.run(LoginManager.java:596)
"Thread-3327":
at
org.jivesoftware.smack.XMPPConnection.disconnect(XMPPConnection.java:440)
- waiting to lock <0x164368b0> (a
org.jivesoftware.smack.XMPPConnection)
at org.jivesoftware.smack.Connection.disconnect(Connection.java:459)
at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.disconnectAndCleanConnection(ProtocolProviderServiceJabberImpl.java:133
1)
at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.connectAndLogin(ProtocolProviderServiceJabberImpl.java:886)
at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.connectAndLogin(ProtocolProviderServiceJabberImpl.java:714)
- locked <0x15047760> (a java.lang.Object)
at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.register(ProtocolProviderServiceJabberImpl.java:437)
at
net.java.sip.communicator.plugin.reconnectplugin.ReconnectPluginActivator$Re
connectTask.run(ReconnectPluginActivator.java:876)
at java.lang.Thread.run(Unknown Source)
"Smack Packet Reader (40)":
at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl.unregister(ProtocolProviderServiceJabberImpl.java:1377)
- waiting to lock <0x15047760> (a java.lang.Object)
at
net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabber
Impl$JabberConnectionListener.connectionClosed(ProtocolProviderServiceJabber
Impl.java:1950)
at
org.jivesoftware.smack.PacketReader.shutdown(PacketReader.java:134)
at
org.jivesoftware.smack.XMPPConnection.shutdown(XMPPConnection.java:402)
at
org.jivesoftware.smack.XMPPConnection.disconnect(XMPPConnection.java:444)
- locked <0x164368b0> (a org.jivesoftware.smack.XMPPConnection)
at org.jivesoftware.smack.Connection.disconnect(Connection.java:459)
at
org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:322)
at
org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

Found 1 deadlock.