Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81739

QNetworkAccessManager creates a deadlock

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • 5.12.4
    • 5.9.5
    • Network: HTTP, Network: SSL
    • None
    • Linux/X11
    • fe6e54f

    Description

      I'm observing that the QNetworkAccessManager is creating a deadlock by doing a BlockingQueuedConnection (QHttpThreadDelegate::preSharedKeyAuthenticationRequired to QNetworkReplyHttpImplPrivate::replyPreSharedKeyAuthenticationRequiredSlot) while holding a lock in QSslSocketBackendPrivate::startHandshake. This is a problem because the thread that owns the QNetworkAccessManager (and could resolve the blocking call) also tries to initiate ssl connections, and is therefor trying to lock the same lock in startHandshake.

      QNetworkAccessManagerThread:
      #0 0x00007ffff3d2a9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7fff5c0810d0) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
      #1 0x00007ffff3d2a9f3 in __pthread_cond_wait_common (abstime=0x0, mutex=0x7fff5c081080, cond=0x7fff5c0810a8) at pthread_cond_wait.c:502
      #2 0x00007ffff3d2a9f3 in __pthread_cond_wait (cond=cond@entry=0x7fff5c0810a8, mutex=mutex@entry=0x7fff5c081080) at pthread_cond_wait.c:655
      #3 0x00007ffff3fe95ab in QWaitConditionPrivate::wait(unsigned long) (time=18446744073709551615, this=0x7fff5c081080) at thread/qwaitcondition_unix.cpp:143
      #4 0x00007ffff3fe95ab in QWaitCondition::wait(QMutex*, unsigned long) (this=this@entry=0x7fff5c082cb8, mutex=mutex@entry=0x7fff5c082cb0, time=time@entry=18446744073709551615)
      {{ at thread/qwaitcondition_unix.cpp:215}}
      #5 0x00007ffff3fe1c1b in QSemaphore::acquire(int) (this=this@entry=0x7fff74fef880, n=n@entry=1) at thread/qsemaphore.cpp:143
      #6 0x00007ffff41f5958 in QMetaObject::activate(QObject*, int, int, void**) (sender=0x7fff8b7157c0, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=5, argv=argv@entry=0x7fff74fef910) at kernel/qobject.cpp:3735
      #7 0x00007ffff41f5d17 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=<optimized out>, m=m@entry=0x7ffff4ed44e0 <QHttpThreadDelegate::staticMetaObject>, local_signal_index=local_signal_index@entry=5, argv=argv@entry=0x7fff74fef910)
      {{ at kernel/qobject.cpp:3629}}
      #8 0x00007ffff4c82df2 in QHttpThreadDelegate::preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*) (this=<optimized out>, _t1=<optimized out>)
      {{ at .moc/moc_qhttpthreaddelegate_p.cpp:532}}
      #9 0x00007ffff4bee02f in QHttpThreadDelegate::preSharedKeyAuthenticationRequiredSlot(QSslPreSharedKeyAuthenticator*) (this=<optimized out>, authenticator=<optimized out>)
      {{ at access/qhttpthreaddelegate.cpp:704}}
      #10 0x00007ffff4c83d4c in QHttpThreadDelegate::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at .moc/moc_qhttpthreaddelegate_p.cpp:248
      #11 0x00007ffff41f5645 in QMetaObject::activate(QObject*, int, int, void**) (sender=0x7fff5c027a30, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=2, argv=argv@entry=0x7fff74fefb30) at kernel/qobject.cpp:3767
      #12 0x00007ffff41f5d17 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=<optimized out>, m=m@entry=0x7ffff4ed4320 <QHttpNetworkReply::staticMetaObject>, local_signal_index=local_signal_index@entry=2, argv=argv@entry=0x7fff74fefb30)
      {{ at kernel/qobject.cpp:3629}}
      {{#13 0x00007ffff4c81eb2 in QHttpNetworkReply::preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*) (this=<optimized out>, _t1=<optimized out>, }}
      {{ _t1@entry=0x7fff74fefd28) at .moc/moc_qhttpnetworkreply_p.cpp:352}}
      #14 0x00007ffff4be323f in QHttpNetworkConnectionChannel::_q_preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*) (this=0x7fff5c116028, authenticator=0x7fff74fefd28) at access/qhttpnetworkconnectionchannel.cpp:1208
      #15 0x00007ffff4be46cc in QHttpNetworkConnectionChannel::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at .moc/moc_qhttpnetworkconnectionchannel_p.cpp:134
      #16 0x00007ffff41f5645 in QMetaObject::activate(QObject*, int, int, void**) (sender=0x7fff8b386650, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=5, argv=argv@entry=0x7fff74fefce0) at kernel/qobject.cpp:3767
      #17 0x00007ffff41f5d17 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=<optimized out>, m=m@entry=0x7ffff4ed33e0 <QSslSocket::staticMetaObject>, local_signal_index=local_signal_index@entry=5, argv=argv@entry=0x7fff74fefce0)
      {{ at kernel/qobject.cpp:3629}}
      #18 0x00007ffff4c56dd2 in QSslSocket::preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*) (this=<optimized out>, _t1=<optimized out>, _t1@entry=0x7fff74fefd28)
      {{ at .moc/moc_qsslsocket.cpp:336}}
      #19 0x00007ffff4c7acdc in QSslSocketBackendPrivate::tlsPskClientCallback(char const*, char*, unsigned int, unsigned char*, unsigned int) (this=
      {{ 0x7fff5c07e8b0, hint=0x0, identity=0x7fff74fefda0 "", max_identity_len=128, psk=0x7fff74fefe30 "", max_psk_len=256) at ssl/qsslsocket_openssl.cpp:1078}}
      #20 0x00007fffbd0e8156 in () at /usr/lib/x86_64-linux-gnu/libssl.so.1.1
      #21 0x00007fffbd0e62eb in () at /usr/lib/x86_64-linux-gnu/libssl.so.1.1
      #22 0x00007fffbd0f024e in () at /usr/lib/x86_64-linux-gnu/libssl.so.1.1
      #23 0x00007fffbd0ef147 in () at /usr/lib/x86_64-linux-gnu/libssl.so.1.1
      #24 0x00007fffbd0db4c4 in SSL_do_handshake () at /usr/lib/x86_64-linux-gnu/libssl.so.1.1
      #25 0x00007ffff4c7b10d in QSslSocketBackendPrivate::startHandshake() (this=this@entry=0x7fff5c07e8b0) at ssl/qsslsocket_openssl.cpp:872
      #26 0x00007ffff4c7b835 in QSslSocketBackendPrivate::startClientEncryption() (this=0x7fff5c07e8b0) at ssl/qsslsocket_openssl.cpp:590
      #27 0x00007ffff4c578cc in QSslSocket::startClientEncryption() (this=this@entry=0x7fff8b386650) at ssl/qsslsocket.cpp:1824
      #28 0x00007ffff4c58578 in QSslSocketPrivate::_q_connectedSlot() (this=0x7fff5c07e8b0)
      {{ at ssl/qsslsocket.cpp:2385}}
      #29 0x00007ffff4c60379 in QSslSocket::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at .moc/moc_qsslsocket.cpp:175
      #30 0x00007ffff41f5645 in QMetaObject::activate(QObject*, int, int, void**)
       
      Other thread:
      #0 0x00007ffff3108839 in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
      #1 0x00007ffff3fdf775 in _q_futex (timeout=0x0, val=3, op=0, addr=0x7ffff4ed8e60 <(anonymous namespace)::Q_QGS__q_sslErrorList::innerFunction()::holder>)
      {{ at thread/qmutex_linux.cpp:121}}
      #2 0x00007ffff3fdf775 in lockInternal_helper<false> (timeout=-1, elapsedTimer=0x0, d_ptr=...) at thread/qmutex_linux.cpp:162
      #3 0x00007ffff3fdf775 in QBasicMutex::lockInternal() (this=0x7ffff4ed8e60 <(anonymous namespace)::Q_QGS__q_sslErrorList::innerFunction()::holder>)
      {{ at thread/qmutex_linux.cpp:178}}
      #4 0x00007ffff3fdf9bb in QMutex::lock() (this=this@entry=0x7ffff4ed8e60 <(anonymous namespace)::Q_QGS__q_sslErrorList::innerFunction()::holder>) at thread/qmutex.cpp:229
      #5 0x00007ffff4c7af96 in QMutexLocker::QMutexLocker(QBasicMutex*) (m=<optimized out>, this=<optimized out>) at ../../include/QtCore/../../src/corelib/thread/qmutex.h:200
      #6 0x00007ffff4c7af96 in QSslSocketBackendPrivate::startHandshake() (this=this@entry=0x7fff8b836350) at ssl/qsslsocket_openssl.cpp:870
      #7 0x00007ffff4c7b835 in QSslSocketBackendPrivate::startClientEncryption() (this=0x7fff8b836350) at ssl/qsslsocket_openssl.cpp:590
      #8 0x00007ffff4c578cc in QSslSocket::startClientEncryption() (this=this@entry=0x7fff8b7eda80) at ssl/qsslsocket.cpp:1824
      #9 0x00007ffff4c58578 in QSslSocketPrivate::_q_connectedSlot() (this=0x7fff8b836350)
      {{ at ssl/qsslsocket.cpp:2385}}
      #10 0x00007ffff4c60379 in QSslSocket::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at .moc/moc_qsslsocket.cpp:175
      #11 0x00007ffff41f5645 in QMetaObject::activate(QObject*, int, int, void**) (sender=sender@entry=0x7fff8b129e80, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x0) at kernel/qobject.cpp:3767

      The thing I don't fully understand yet is why pre-shared key authentication gets triggered in the first place, as far as I know it's a fairly obscure mode. Is this normal?

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              tpochep Timur Pocheptsov
              leont Leon Timmermans
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes