Mumble: Qt 5.11 doesn't allow an SQL connection to be passed between threads

Created on 27 May 2018  ·  23Comments  ·  Source: mumble-voip/mumble

Good day.

If i try to connect to my server i get a popup that the server changed its certificate. But if I view them they are exactly the same. On stdout i get:

<W>2018-05-27 20:01:03.776 CELT bitstream 8000000b from /usr/lib/mumble/libcelt0.so.0.7.0
<W>2018-05-27 20:01:03.776 CELT bitstream 80000010 from /usr/lib/mumble/libcelt0.so.0.11.0
<W>2018-05-27 20:01:03.776 Directory  "/home/ranomier/.local/share/Mumble/Mumble/Themes/omega-for-mumble"  has no theme.ini, trying fallback
<W>2018-05-27 20:01:03.776 Theme: "Mumble"
<W>2018-05-27 20:01:03.776 Style: "Lite"
<W>2018-05-27 20:01:03.777 --> qss: ":builtin/themes/Mumble/Lite.qss"
<W>2018-05-27 20:01:03.777 Locale is "en_DE" (System: "en_DE")
<W>2018-05-27 20:01:03.782 TextToSpeech: Compiled without support for speech-dispatcher
<W>2018-05-27 20:01:03.881 Database SQLite: "3.23.1"
<W>2018-05-27 20:01:03.881 Overlay: Listening on "/run/user/1000/MumbleOverlayPipe"
<W>2018-05-27 20:01:03.888 Icon theme "ubuntu-mono-dark" not found.
<W>2018-05-27 20:01:03.888 Icon theme "gnome" not found.
<W>2018-05-27 20:01:03.900 Updating application palette
<W>2018-05-27 20:01:03.917 GlobalShortcutX: Using XI2 2.3
<W>2018-05-27 20:01:04.157 AudioInput: Opus encoder set for VOIP
<W>2018-05-27 20:01:04.157 AudioInput: 72000 bits/s, 48000 hz, 480 sample
<W>2018-05-27 20:01:04.158 PulseAudio: Starting input jack_in
<W>2018-05-27 20:01:04.158 PulseAudio: Starting output: jack_out
<W>2018-05-27 20:01:04.158 AudioOutput: Initialized 1 channel 48000 hz mixer
<W>2018-05-27 20:01:04.159 AudioInput: Initialized mixer for 1 channel 48000 hz mic and 0 channel 48000 hz echo
warning: The VAD has been replaced by a hack pending a complete rewrite




<W>2018-05-27 20:01:10.073 OpenSSL Support: 1 (OpenSSL 1.1.0h  27 Mar 2018)
<W>2018-05-27 20:01:10.103 ServerHandler: TLS cipher preference is "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:AES256-SHA:AES128-SHA"
<W>2018-05-27 20:01:10.269 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-05-27 20:01:10.269 QSqlQuery::prepare: database not open
<W>2018-05-27 20:01:10.269 SQL Query failed ""
<W>2018-05-27 20:01:10.269 -1 "Driver not loaded Driver not loaded"
<W>2018-05-27 20:01:11.690 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-05-27 20:01:11.690 QSqlQuery::prepare: database not open
<W>2018-0``5-27 20:01:11.690 SQL Query failed ""
<W>2018-05-27 20:01:11.690 -1 "Driver not loaded Driver not loaded"

Realy weird

client prioritP0 - Blocker qt

Most helpful comment

I updated the pull request, now each thread requiring access to the database has its own connection with it.

All 23 comments

Your system is probably missing the SQLite client library, which is required in order to load the QSQLite database driver.

What Linux distribution are you using?

I talked with @Natenom, who is using Arch Linux and is encountering the same issue.

The QSQLite library is present and all of its dependencies are installed, there seems to be a problem with Qt 5.11.

For reference, the message QSqlDatabasePrivate::database: requested database does not belong to the calling thread. was introduced in commit 9b361f0 and then fixed in commit e729ac6, so that it is only printed in case the database is valid.

EDIT: just realized thats a qt bug.

So do you need more information or is the bug fixed with the new release? And is it in the new snapshot?

Thank you for you quick answer! :3 :1st_place_medal:

I will try to build Mumble with Qt 5.11 on another distribution, in order to check whether the problem is related to the version shipped with Arch Linux or not.

Reproduced on arch linux too:

<W>2018-06-07 00:03:32.522 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-07 00:03:32.522 QSqlQuery::prepare: database not open
<W>2018-06-07 00:03:32.522 SQL Query failed ""
<W>2018-06-07 00:03:32.522 -1 "Driver not loaded Driver not loaded"

Some folks on arch linux downgraded Qt5 and everything ran smoothly. This seems to be general to arch. For reference:
https://aur.archlinux.org/packages/mumble-git/

Any news?

Edit: Correct link to AUR.

Per https://bugreports.qt.io/browse/QTBUG-68486 it sounds like this error is intended behavior and not an upstream bug -- passing the database object between threads isn't allowed.

@Nephyrin You're right, thank you very much.

At first I thought that in Qt 5.11 only a dedicated error message was added and passing a QSqlDatabase object between threads was never allowed.

QTBUG-216 was opened in 2006, more than a decade ago. I assume that back then QSqlDatabase was quite different.

I created #3419 to solve the issue; could someone on Arch Linux test it and check whether it works as expected, please?

I can confirm that #3419 fixes this for me with Qt 5.11. Thanks for the quick fix!

Thank you for testing it!

Although! Connecting and functionality seems to work fine now, but I still see this in stdout:

<W>2018-06-09 17:08:52.437 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-09 17:08:52.437 QSqlQuery::prepare: database not open
<W>2018-06-09 17:08:52.437 SQL Query failed ""
<W>2018-06-09 17:08:52.437 -1 "Driver not loaded Driver not loaded"
<W>2018-06-09 17:08:52.617 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-09 17:08:52.617 QSqlQuery::prepare: database not open
<W>2018-06-09 17:08:52.617 SQL Query failed ""
<W>2018-06-09 17:08:52.617 -1 "Driver not loaded Driver not loaded"
<W>2018-06-09 17:08:52.619 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-09 17:08:52.619 QSqlQuery::prepare: database not open
<W>2018-06-09 17:08:52.619 SQL Query failed ""
<W>2018-06-09 17:08:52.619 -1 "Driver not loaded Driver not loaded"

.. So it seems like there are a few less-critical spots still failing their sqlite access

I fixed them right now.

Could you test again, please?

With those changes I now see:

<W>2018-06-09 22:58:02.558 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-09 22:58:02.558 QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
<W>2018-06-09 22:58:02.592 Database SQLite: "3.24.0"
<W>2018-06-09 22:58:02.734 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-09 22:58:02.735 QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
<W>2018-06-09 22:58:02.762 Database SQLite: "3.24.0"
<W>2018-06-09 22:58:03.195 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-09 22:58:03.196 QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
<W>2018-06-09 22:58:03.211 Database SQLite: "3.24.0"
<W>2018-06-09 22:58:18.788 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-09 22:58:18.788 QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
<W>2018-06-09 22:58:18.801 Database SQLite: "3.24.0"
<W>2018-06-09 22:58:22.682 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-09 22:58:22.682 QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
<W>2018-06-09 22:58:22.719 Database SQLite: "3.24.0"

Which may be expected? I no longer see any SQL Query failed output.

After the recent changes I'm getting a segmentation fault:

<W>2018-06-10 12:29:31.080 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-10 12:29:31.081 QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
<W>2018-06-10 12:29:31.150 Database SQLite: "3.24.0"
<W>2018-06-10 12:29:31.211 OSInfo: Failed to execute lsb_release
<W>2018-06-10 12:29:31.415 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-10 12:29:31.415 QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
<W>2018-06-10 12:29:31.475 Database SQLite: "3.24.0"
<W>2018-06-10 12:29:31.899 QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
<W>2018-06-10 12:29:31.899 QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
[1]    9175 segmentation fault  mumble

And in the kernel buffer:

[92560.294444] mumble[9175]: segfault at 40ee9 ip 00007fb4682c0e7e sp 00007ffdc033e000 error 6 in libsqlite3.so.0.8.6[7fb468251000+114000]

But this could be due to a recent sqlite update on my system. I'll recompile qt5.

I updated the pull request, now each thread requiring access to the database has its own connection with it.

Everything is recompiled and works again -- merci beaucoup!

You're welcome!

The pull request can still be improved, at the moment it takes some seconds to load the channels tree when connecting to a server.

Done.

Please check one last time if everything works as expected.

With the most-recent changes I no longer see any odd SQL spew and everything seems to work. I changed a few settings and relaunched to ensure they persist, etc..

Thanks again for your work on this!

You're welcome, thank you for testing!

Same here! :+1:

Same here!
Thanks a lot.

You're welcome!

Once someone reviews the pull request, I will merge it immediately.

Thank you :+1: :1st_place_medal:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Teteros picture Teteros  ·  4Comments

TalkLounge picture TalkLounge  ·  4Comments

mumble-voip picture mumble-voip  ·  4Comments

promi picture promi  ·  5Comments

felix91gr picture felix91gr  ·  4Comments