Bug 239349

Summary: deskutils/nextcloudclient: segfault on nextcloud because of glib2
Product: Ports & Packages Reporter: lfen <lfen>
Component: Individual Port(s)Assignee: Michael Reifenberger <mr>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: contact, mail, mikael, stephan, tech-lists, w.schwarzenfeld
Priority: --- Flags: w.schwarzenfeld: maintainer-feedback?
Version: Latest   
Hardware: amd64   
OS: Any   

Description lfen 2019-07-20 17:26:26 UTC
packages: nextcloudclient and glib-2 

nextcloudclient was working fine, until 2 days ago.
I dont know why, but I get segfault and the issue may be in glib-2

I just had to start nextcloud to get the crash (after maybe 2 seconds of wait).

Here is what gdb see at crash time.

Thread 1 received signal SIGSEGV, Segmentation fault.
0x000000080d40772f in g_strfreev () from /usr/local/lib/libglib-2.0.so.0
(gdb) bt
#0  0x000000080d40772f in g_strfreev () at /usr/local/lib/libglib-2.0.so.0
#1  0x000000080d43115a in g_spawn_command_line_sync () at /usr/local/lib/libglib-2.0.so.0
#2  0x000000080d2582c1 in  () at /usr/local/lib/libgio-2.0.so.0
#3  0x000000080d257e5d in g_dbus_address_get_for_bus_sync () at /usr/local/lib/libgio-2.0.so.0
#4  0x000000080d264578 in  () at /usr/local/lib/libgio-2.0.so.0
#5  0x000000080d264679 in g_bus_get () at /usr/local/lib/libgio-2.0.so.0
#6  0x000000080bbd80aa in  () at /usr/local/lib/libsecret-1.so.0
#7  0x000000080d1d4837 in g_async_initable_new_valist_async () at /usr/local/lib/libgio-2.0.so.0
#8  0x000000080d1d4754 in g_async_initable_new_async () at /usr/local/lib/libgio-2.0.so.0
#9  0x000000080bbd582b in secret_service_get () at /usr/local/lib/libsecret-1.so.0
#10 0x000000080bbd06f7 in secret_service_lookup () at /usr/local/lib/libsecret-1.so.0
#11 0x000000080bbd2b1c in secret_password_lookup () at /usr/local/lib/libsecret-1.so.0
#12 0x0000000801b92e45 in LibSecretKeyring::findPassword(QString const&, QString const&, QKeychain::JobPrivate*) () at /usr/local/lib/libqt5keychain.so.1
#13 0x0000000801b8b833 in QKeychain::ReadPasswordJobPrivate::scheduledStart() () at /usr/local/lib/libqt5keychain.so.1
#14 0x0000000801b8adaa in QKeychain::JobExecutor::startNextIfNoneRunning() () at /usr/local/lib/libqt5keychain.so.1
#15 0x0000000801b8a47c in QKeychain::JobExecutor::enqueue(QKeychain::Job*) () at /usr/local/lib/libqt5keychain.so.1
#16 0x000000080cc6a7d1 in QObject::event(QEvent*) () at /usr/local/lib/qt5/libQt5Core.so.5
#17 0x000000080be819e1 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/local/lib/qt5/libQt5Widgets.so.5
#18 0x000000080be82f28 in QApplication::notify(QObject*, QEvent*) () at /usr/local/lib/qt5/libQt5Widgets.so.5
#19 0x000000080cc3e111 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/local/lib/qt5/libQt5Core.so.5
#20 0x000000080cc3f1e3 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/local/lib/qt5/libQt5Core.so.5
#21 0x000000080cc97b78 in  () at /usr/local/lib/qt5/libQt5Core.so.5
#22 0x000000080d3e6b77 in g_main_context_dispatch () at /usr/local/lib/libglib-2.0.so.0
#23 0x000000080d3e6f03 in  () at /usr/local/lib/libglib-2.0.so.0
#24 0x000000080d3e6fb4 in g_main_context_iteration () at /usr/local/lib/libglib-2.0.so.0
#25 0x000000080cc97546 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/local/lib/qt5/libQt5Core.so.5
#26 0x000000080cc39a0e in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/local/lib/qt5/libQt5Core.so.5
#27 0x000000080cc3e82e in QCoreApplication::exec() () at /usr/local/lib/qt5/libQt5Core.so.5
#28 0x000000000118ff73 in  ()
#29 0x000000000117d10b in  ()
#30 0x00000008012e0000 in  ()
#31 0x0000000000000000 in  ()


My log file
[OCC::Application::setupLogging 	"################## Nextcloud locale:[en_US] ui_lang:[] version:[2.5.3git] os:[FreeBSD 12.0-RELEASE-p7]"
[OCC::(anonymous namespace)::applicationTrPath 	Running from build location! Translations may be incomplete!
[OCC::Application::setupTranslations 	Using "en_US" translation
[unknown 	QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-abdel'
[OCC::SocketApi::SocketApi 	server started, listening at  "/tmp/runtime-abdel/Nextcloud/socket"
[OCC::FolderMan::FolderMan 	setting remote poll timer interval to 5000 msec
[OCC::AccountManager::loadAccountHelper 	Account for QUrl("https://192.168.5.2") using auth type "webflow"
[OCC::WebFlowCredentials::createQNAM 	Get QNAM
[OCC::ownCloudGui::setupContextMenu 	Tray menu workarounds: noabouttoshow: false fakedoubleclick: false showhide: false manualvisibility: false
[OCC::AccessManager::createRequest 	6 "GET" "https://192.168.5.2/ocs/v2.php/core/navigation/apps?absolute=true&format=json" has X-Request-ID "14495008-9794-43db-b136-32284ddabe48"
[OCC::AbstractNetworkJob::start 	OCC::OcsNavigationAppsJob created for "https://192.168.5.2" + "ocs/v2.php/core/navigation/apps" ""
[OCC::FolderMan::setupFolders 	Setup folders from settings file
[OCC::ConfigFile::setupDefaultExcludeFilePaths 	Adding user defined ignore list to csync: "/home/abdel/.config/Nextcloud/sync-exclude.lst"
[OCC::FolderMan::addFolderInternal 	Adding folder to Folder Map  OCC::Folder(0x81aece800) "1"
[OCC::FolderMan::scheduleFolder 	Schedule folder  "1"  to sync!
[OCC::FolderMan::scheduleFolder 	Folder is not ready to sync, not scheduled!
[OCC::ownCloudGui::slotSyncStateChange 	Sync state changed for folder  "https://192.168.5.2/remote.php/webdav/" :  "Not yet Started"
[OCC::SyncJournalDb::checkConnect 	sqlite3 version "3.28.0"
[OCC::SyncJournalDb::checkConnect 	sqlite3 journal_mode= "wal"
[OCC::ClientProxy::setupQtProxyFromConfig 	Set proxy configuration to use the prefered system proxy for http tcp connections
[OCC::WebFlowCredentials::fetchFromKeychain 	Fetch from keyhchain!
[unknown 	static bool LibSecretKeyring::findPassword(const QString &, const QString &, QKeychain::JobPrivate *)


to get this log I ran the application with following argument
nextcloud  --logflush --logdebug --logdir /tmp/nxtcdbg

other info:
# nextcloud --version
Nextcloud version 2.5.2git
Git revision ca624def40d5e431bc84a157ffba1bc187d5ecee
Using Qt 5.12.2, built against Qt 5.12.2
Using 'OpenSSL 1.1.1a-freebsd  20 Nov 2018'

# which nextcloud
/usr/local/bin/nextcloud

Important note:
All packages were installed using binary packages (pkg command). And I tried to remove glib-2 and I installed it from ports (/usr/ports/devel/glib20), and I added -g flag and enabled debugging and now nextcloud is working again.

And yes my binaris were updated when i had the crash. (few hours ago from now)
Comment 1 Michael Reifenberger freebsd_committer freebsd_triage 2019-11-08 14:31:50 UTC
Hi,
please retest using the new nectcloudclient version 2.6.1
Comment 2 Evilham 2020-05-24 10:21:40 UTC
Hello,

I was just about to open an issue regarding this on 13-CURRENT. Ran with gdb and --logdebug as well and have the same stack trace.

[OCC::SyncJournalDb::checkConnect 	sqlite3 version "3.31.1"
[OCC::SyncJournalDb::checkConnect 	sqlite3 journal_mode= "wal"
[OCC::ClientProxy::setupQtProxyFromConfig 	Set proxy configuration to use the prefered system proxy for http tcp connections
[OCC::WebFlowCredentials::fetchFromKeychain 	Fetch from keychain!
[unknown 	static bool LibSecretKeyring::findPassword(const QString &, const QString &, QKeychain::JobPrivate *)


This was working with current NextCloud version and then stopped working some weeks ago.

> nextcloud --version
Nextcloud version 2.6.4git
Git revision b45f5fd1a947dc21eb11c69049a99616a2ec950e
Using Qt 5.14.2, built against Qt 5.14.2
Using 'OpenSSL 1.1.1g-freebsd  21 Apr 2020'

> pkg info glib
glib-2.56.3_7,1

> pkg info qtkeychain
qtkeychain-0.10.0



Is there something I can help testing?
Comment 3 Evilham 2020-06-01 10:44:11 UTC
Some new information:

I've been told that absence of dbus results in this error as well, so if someone hits this, they should make sure dbus is running (it's needed for communication with the keyring).


But that wasn't my issue, for some reason I managed to solve this on my system by nuking NextCloud-client's configuration and the keyring (which I only use for this program).
(~/.config/Nextcloud and ~/.local/share/keyrings, nuke at your own risk, beware of dataloss, perform backups, and all that)

After that the program has been working flawlessly.
Maybe there is some weird edge case that causes the configuration to become invalid and it fails utterly.
Comment 4 tech-lists 2020-09-02 20:51:47 UTC
I've just had this problem and the fix was to remove ~/.config/Nextcloud and ~/.local/share/keyrings and reinstall nextcloudclient.

context is:

nextcloud --version
Nextcloud version 2.6.5git
Git revision adada8b2eecd65d7a587b6abe0ae2aabca9a0b75
Using Qt 5.15.0, built against Qt 5.15.0
Using Qt platform plugin 'xcb'
Using 'OpenSSL 1.1.1g-freebsd  21 Apr 2020'
Running on FreeBSD 12.1-STABLE, x86_64

Because the config was removed, had to re-set-up the client. The port was built in a poudriere that runs every night.
Comment 5 Stephan Lichtenauer 2020-09-23 06:03:23 UTC
I can confirm this problem with the latest 2.6.4 from pkg on 12.1 and to me it looks like the configuration becomes invalid after a certain amount of time. 

Removing the configuration and starting from scratch makes the client work again for some time, but at some point the problem repeats itself.

From looking at https://github.com/nextcloud/desktop/issues?q=is%3Aissue+is%3Aopen+segfault it might seem that the issue is not specific to FreeBSD.
Comment 6 Stephan Lichtenauer 2020-09-23 17:33:14 UTC
I just noticed one more thing: 

When nextcloud segfaults, synchronising the directory once with nextcloudcmd seems to (at least sometimes) fix the corrupted sync state data so that subsequently nextcloud also works again without the need to start from scratch,
Comment 7 Michael Reifenberger freebsd_committer freebsd_triage 2020-09-25 18:03:01 UTC
I just updated the port to 3.0.2
Could you please test if it behaves differently (hopefully better).
Comment 8 Stephan Lichtenauer 2020-10-12 06:22:00 UTC
Thank you very much Michael, since the upgrade the client is stable again.

So to me it seems it was clearly related to the old 2.x version and from my side this bug could be closed.
Comment 9 Evilham 2020-10-12 08:04:15 UTC
I also haven't observed this issue in a long time :-). Maybe we (someone with permissions) can close this as "Overcome by external events"?