Bug 381929 - Feeds list gets corrupted when akregator is restored on log in
Summary: Feeds list gets corrupted when akregator is restored on log in
Status: RESOLVED FIXED
Alias: None
Product: akregator
Classification: Applications
Component: general (show other bugs)
Version: 5.5.2
Platform: openSUSE Linux
: NOR grave
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 384223 386000 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-07-02 18:16 UTC by Christian Boltz
Modified: 2018-02-26 05:49 UTC (History)
26 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.7.3


Attachments
Exit slotSaveFeedList() if feed is empty without writing anyfiles (478 bytes, patch)
2018-02-10 16:06 UTC, Mark Gannon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Boltz 2017-07-02 18:16:29 UTC
(initially reported as http://bugzilla.opensuse.org/show_bug.cgi?id=1046966 )

Since I installed the 20170613 openSUSE Tumbleweed snapshot, Akregator looses/breaks its feed list. The only good thing is that the error message mentions the exact filename (~/.local/share/akregator/data/feeds.opml) so that it's easy to restore from my backup.

The not-so-good thing is that Akregator even breaks the backup file, so when this happens, both feeds.opml and the feeds.opml-backup.* file are only one byte (hexdump says "000a", so just a newline).

I had to restore the file several times already. I'm not 100% sure, but I wouldn't be surprised if the file gets damaged on logout/shutdown.
Explicitely exiting Akregator (by pressing Ctrl-Q) before logging out seems to avoid the breakage.

After restoring feeds.opml, Akregator can be started normally and shows all my feeds.


This bug was confirmed by multiple users on opensuse-factory, both with Tumbleweed and with 42.2 + KDE:Frameworks5.
Comment 1 Christian Lichtsinn 2017-07-12 05:29:08 UTC
I can confirm this behaviour on Arch Linux, same version. Though it does not occur regulary. It does crash on start, like in the other bug reports. And sometimes the complete feed list is lost.
Comment 2 Bernd Steinhauser 2017-07-15 11:53:36 UTC
Possibly a duplicate of bug 381822.

Anyway, I started to see this problem as well and it started exactly after I upgraded Qt from 5.8.0 to 5.9.1.
I did rebuild Akregator and it's dependencies (up from Qt, obviously), but that didn't help either.
Comment 3 Bernd Steinhauser 2017-07-16 07:48:58 UTC
Just wanted to add that I observed this bug as well when I close Akregator manually.
Comment 4 Christian Boltz 2017-07-16 13:05:51 UTC
(In reply to Bernd Steinhauser from comment #3)
> Just wanted to add that I observed this bug as well when I close Akregator
> manually.

Please define "close manually" ;-)
a) click the "x" icon to close the window
b) press Alt+F4
c) press Ctrl+q
d) using the menu File - Quit

a) and b) only close the main window, Akregator will still run and display its tray icon.

c) and d) will really quit Akregator - and after closed this way, I've never seen the trashed feed list IIRC.
Comment 5 Bernd Steinhauser 2017-07-16 13:27:58 UTC
(In reply to Christian Boltz from comment #4)
> (In reply to Bernd Steinhauser from comment #3)
> d) using the menu File - Quit
I chose
e) right-click on the tray icon and choose Quit, which should be the same thing. Next start of Akregator (without rebooting) -> list trashed
Comment 6 Bernd Steinhauser 2017-07-16 13:30:06 UTC
Maybe I should add that I've seen the corruption after quitting Akregator only once (out of 10-20 times), it seems much more unlikely.
When you don't specifically close Akregator before reboot, it seems much more likely that the list gets corrupted (maybe 2 out of 3 times).

To me this smells like some sort of race condition.
Comment 7 Christophe Marin 2017-07-16 16:52:59 UTC
(In reply to Bernd Steinhauser from comment #2)
> Possibly a duplicate of bug 381822.
> 
unrelated to this report. Akregator doesn't crash.
Comment 8 Bernd Steinhauser 2017-07-16 18:17:50 UTC
Just tried again and it's definitely not only on log in.
Took me maybe 10 restarts of Akregator until I got the message that the feed list is corrupted.
In that case it also told me that Akregator didn't close properly, although there was no indication of a crash (no coredump, no bug message etc.).
Comment 9 Christophe Marin 2017-07-16 22:16:28 UTC
did it start refreshing a feed when you closed it ?
Comment 10 Bernd Steinhauser 2017-07-17 16:52:10 UTC
(In reply to Christophe Giboudeaux from comment #9)
> did it start refreshing a feed when you closed it ?

Sorry, did not pay attention to that, so can't really tell.

Afterwards, I did try to enforce that by hitting the fetch all feeds button and then closing Akregator, but it didn't trigger this.
Comment 11 Evstifeev Roman 2017-10-21 08:31:18 UTC
I can confirm this with 
Akregator 5.6.1 on openSUSE Tumbleweed.
KDE Frameworks 5.38.0
Qt 5.9.1 (built against 5.9.1)
The xcb windowing system

WORKAROUND to restore feeds:
Despite window said that the backup was saved - it was empty file.
I managed to resore my feeds from file:///home/u1/.local/share/akregator/Archive/feedlistbackup.mk4 - that file holds history. I opened it with kate and noticed that it is a binary file, but parts of it has exact same xml structure as my lost feeds.opml. So i found part that looked like my most recent feeds list (<outline >...</outline>) and copied it into file:///home/u1/.local/share/akregator/data/feeds.opml
Comment 12 Christophe Marin 2017-10-21 19:34:50 UTC
*** Bug 386000 has been marked as a duplicate of this bug. ***
Comment 13 Christoph Feck 2017-10-25 11:41:05 UTC
*** Bug 384223 has been marked as a duplicate of this bug. ***
Comment 14 Christos Gourdoupis 2017-12-16 21:49:26 UTC
I have been trying to debug this and have now reached a point where I can reproduce it every time under the debugger (kdevelop). This is what happens:
1. akregator starts with a healthy feeds.opml and creates a similar feeds.opml~
2. I do some stuff and then close the window and terminate the program from the system tray icon.
3. In MainWidget::slotOnShutdown(), setFeedList is called with an empty list.
4. Upon setFeedList() exit a QSharedPointer<FeedList> oldList which holds the feedlist is deleted.
5. In ~FeedList() destructor, setRootNode(0) is called.
6. In setRootNode(0), delete d->rootNode truncates feeds.opml to length of 1 byte.
7. The program exits NORMALLY. At this point feeds.opml~ contains a good backup.
8. On next program start, feeds.opml is "saved" to feeds.opml~ effectively destroying it. The program complains for an invalid feed list and saves an equally useless feeds.opml-backup.*

Does that help at all? Is there anything I can do?
Comment 15 Christoph Feck 2018-01-01 17:36:40 UTC
Thanks Christos for the analysis. Do you think you are able to suggest a patch to fix this issue?
Comment 16 Steve 2018-01-12 16:12:09 UTC
Just wanted to add that this also happens on Fedora 26 and 27 (with all updates applied).

The procedure in Comment 14 also works for me, ie it reproducible destroys the feeds every time. 

Otherwise, the feed corruption is more hit and miss, ie it doesn't happen every time I start Akregator but often enough to be annoying.
Comment 17 Christos Gourdoupis 2018-01-12 21:48:20 UTC
Unfortunately, with the updated 17.12.0 sources I cannot reproduce it in the debugger, no matter what.
On the bright side, the corruption has not occured once since the update.
We'll see.
Comment 18 Christoph Feck 2018-01-30 00:32:53 UTC
Did anyone else see feedlist corruption with the 17.12.x release (Akregator version 5.7.x)?
Comment 19 Andrius Štikonas 2018-01-30 00:34:04 UTC
(In reply to Christoph Feck from comment #18)
> Did anyone else see feedlist corruption with the 17.12.x release (Akregator
> version 5.7.x)?

Yes, I have it too on 17.12.1 with Qt 5.9.3.
Comment 20 tomas nackaerts 2018-01-30 16:26:22 UTC
(In reply to Christoph Feck from comment #18)
> Did anyone else see feedlist corruption with the 17.12.x release (Akregator
> version 5.7.x)?

still happens with version 5.7.1
Comment 21 Mark Gannon 2018-02-05 23:12:31 UTC
When I shutdown akregator (from gentoo's 17.12.1 package) I experience this problem and get the following output at the terminal:

[1:1:0205/180714.662998:ERROR:broker_posix.cc(41)] Invalid node channel message
[1:1:0205/180714.674483:ERROR:broker_posix.cc(41)] Invalid node channel message
[1:1:0205/180714.686681:ERROR:broker_posix.cc(41)] Invalid node channel message
[1:1:0205/180714.697479:ERROR:broker_posix.cc(41)] Invalid node channel message
kf5.kxmlgui: 0x563be92f3b10 deleted without having been removed from the factory first. This will leak standalone popupmenus and could lead to crashes.
[1:1:0205/180714.727815:ERROR:broker_posix.cc(41)] Invalid node channel message
[1:1:0205/180714.727927:ERROR:broker_posix.cc(41)] Invalid node channel message
[1:1:0205/180714.728664:ERROR:broker_posix.cc(41)] Invalid node channel message
[1:1:0205/180714.728952:ERROR:broker_posix.cc(41)] Invalid node channel message

Perhaps its a different issue, but it does happen when I exit akregator (and when I start the feed has to be reimported).
Comment 22 Mark Gannon 2018-02-10 16:06:02 UTC
Created attachment 110511 [details]
Exit slotSaveFeedList() if feed is empty without writing anyfiles

The last time slotSaveFeedList() was being called with an empty feed list.  The attached patch checks to see if the feed is null, and if so, returns without writing any files.
Comment 23 Frederik Schwarzer 2018-02-10 21:10:34 UTC
Thanks for the proposed patch. I was hit by that problem today and am still panicking a bit while restoring my feeds. :D

I am not that familiar with the Qt pointers but might a QScopedPointer be enough here?
Comment 24 Mark Gannon 2018-02-11 14:24:26 UTC
Sorry.  Its been a long time since I did any c++.  I tried changing to:

+    QScopedPointer<FeedList> f_list = m_mainWidget->allFeedsList();                                                 
+    if (f_list.isNull()) {                                                                                          
+       return;                                                                                                      
+    }                                                                                                               
+ 

And got the following error:
/var/tmp/portage/kde-apps/akregator-17.12.1/work/akregator-17.12.1/src/akregator_part.cpp: In member function ‘void Akregator::Part::slotSaveFeedList()’:
/var/tmp/portage/kde-apps/akregator-17.12.1/work/akregator-17.12.1/src/akregator_part.cpp:529:65: error: conversion from ‘QSharedPointer<Akregator::FeedList>’ to non-scalar type ‘QScopedPointer<Akregator::FeedList>’ requested
     QScopedPointer<FeedList> f_list = m_mainWidget->allFeedsList();
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~

Perhaps I'm using it wrong?
Comment 25 Andreas Sturmlechner 2018-02-12 11:30:08 UTC
Thanks Mark, please submit your patch on https://phabricator.kde.org/ to get a proper review.
Comment 26 Laurent Montel 2018-02-12 15:54:53 UTC
I try to reproduce this problem but I can't.
Do you launch akregator in console ? 
Do you launch kontact ?

I can't reproduce fro the moment after 15 try I didn't have this bug...
Comment 27 Piotr Keplicz 2018-02-12 16:02:57 UTC
It happens in my setup:
* up-to-date Neon User edition,
* kontact is started using the session on login,
* kontact sometimes crashes on logout (I'm unable to get the trace since DrKonqi quits when the session ends a couple of seconds after the crash),
* on next login, kontact starts and akregator's feeds list is empty.
Comment 28 Frederik Schwarzer 2018-02-12 16:48:05 UTC
@Mark: Nah, it's more likely that my comment was stupid. :D
I did not look at the API so a shared pointer will likely be the way to go. But as Andreas said, going through proper code review will be better anyway.

@Laurent: for me it is just plain Akregator being started and stopped by KDE session management. The problem only hit me once so far, though.
Comment 29 avlas 2018-02-19 21:36:08 UTC
This happens to me with Akregator embedded in Kontact. It doesn't happen 100% of the times, but it does quite frequently.

Cannot tell for sure, but I have the feeling that this happens more frequently when I set Kontact to autostart at login (perhaps because the system under larger load ? or perhaps its just my false impression).
Comment 30 Andrius Štikonas 2018-02-19 21:49:14 UTC
We have been testing attached patch on Gentoo. So far feeds did not get corrupted when this patch was applied. Without it we saw some reports fairly quickly.
Comment 31 Andreas Sturmlechner 2018-02-25 17:01:51 UTC
Mark, your action is required for the phabricator revision to proceed, did you receive a notification?
Comment 32 Laurent Montel 2018-02-26 05:49:15 UTC
Git commit 6678efb711e2cc6ee852e7331ff5185ddeba872d by Laurent Montel.
Committed on 26/02/2018 at 05:47.
Pushed by mlaurent into branch 'Applications/17.12'.

Apply patch from mgannon

Prevent Akregator from overwriting feeds.opml with an emtpy feed list
FIXED-IN: 5.7.3

Quitting akregator causes ~/.local/share/akregator/data/feeds.opml to be overwritten using an empty feed
list with the result that upon relaunching an error message appears and only the standard built in feeds are available.

In troubleshooting the issue, I noticed that slotSaveFeedList() is called five times between quitting the
program and the program is finally shutdown. It is only the last time that the function is called with
an empty list. This implies that there might be an error in the slot logic, since
the function should only need to be called once. The attached patch seemed the easiest way to deal with the issue.

Test Plan

i. Start a clean installation of akregator.
ii. Import a list of feeds from an opml file.
iii. Logout from the kde desktop
iv. Login into the kde desktop.

Without the patch, an error message appears saying it is unable to open the file.

Differential Revision: https://phabricator.kde.org/D10466

M  +4    -0    src/akregator_part.cpp

https://commits.kde.org/akregator/6678efb711e2cc6ee852e7331ff5185ddeba872d