Bug 412705 - Konsole leaves hundreds of megabytes in thousands of temp history files
Summary: Konsole leaves hundreds of megabytes in thousands of temp history files
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: history (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-07 17:27 UTC by Tim E. Real
Modified: 2019-10-24 16:56 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 19.12.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim E. Real 2019-10-07 17:27:52 UTC
SUMMARY
Every week I must manually clean out thousands of
 konsole-*.history temporary files from /tmp totaling
 hundreds of megabytes.

STEPS TO REPRODUCE
1. Use konsole for some days or weeks.

OBSERVED RESULT
Low disk space on drive, sometimes causing complete
 failure to boot system.
Must manually clean them out from /tmp, sometimes
 from another distro before even being able to boot.
Average user has no clue what is going on behind their back,
 and why the system won't boot.

EXPECTED RESULT
There should be no history files hanging around
 when konsole is not running.

SOFTWARE/OS VERSIONS
OpenSUSE Tumbleweed.

ADDITIONAL INFORMATION
Please make konsole clean up after itself when it closes.
Even better: When konsole starts, please check if stale history
 file are hanging around and delete them before continuing.
(Can you see the bizarre irony that these are supposed to be
 'temporary' files but they hang around forever?)

Thank you.
Comment 1 Kurt Hindenburg 2019-10-08 00:52:48 UTC
By any chance is Konsole crashing at some point?  Or is your system crashes or quitting the desktop?  Otherwise, Konsole should remove those upon a clean quit. 

I don't think Konsole can clean out those files upon startup since another Konsole could be running.

Also what version are you running?
Comment 2 Mariusz Glebocki 2019-10-08 07:44:50 UTC
Create + open + unlink should fix any possible problem with leftover files. From man 2 unlink:

       unlink() deletes a name from the filesystem.  If that name was the last
       link to a file and no processes have the file open, the file is deleted
       and the space it was using is made available for reuse.

       If  the  name  was the last link to a file but any processes still have
       the file open, the file will remain in existence until  the  last  file
       descriptor referring to it is closed.
Comment 3 Tim E. Real 2019-10-08 16:10:50 UTC
Thank you for the response.
Konsole (ver 19.08.1) does not crash, nor the system.
The only thing I can think of that might be unusual
 is that I leave Konsole open when I shut down,
 ie. I leave Konsole open all the time so that
 it is opened upon reboot.

I will try some experiments to see if that might
 be the problem, maybe Konsole is not being given
 enough time to clean up as the system shuts down.

Until recently Konsole was indeed frequently crashing upon shutdown.
That appears to have been fixed here in openSuse Tumbleweed.
But the temp files still seem to be appearing and left around
 despite cleaning.
Comment 4 Tim E. Real 2019-10-08 22:16:09 UTC
Verified: Konsole cleans up after itself if I manually close it.

But Konsole does not clean up if left open and reboot.

I began with a clean plate and started Konsole and verified
 it cleans up if I close it.
But if I leave Konsole open and reboot, the temp files are still there.

Each time I reboot, a whole new set of Konsole temp files appears.
After several reboots, I now have dozens of files.

Hope I'm not 'barking up the wrong tree'. Maybe a system problem?
(Seems that's taking reboot 'restoration' to an extreme. Is normal?)
I have several apps open but none seem to use temp files.
I will try to find another app which uses temp files and verify.
Any suggestions or ideas of cause?
Thanks.
Comment 5 Tim E. Real 2019-10-08 22:30:15 UTC
I almost forgot, KDevelop is another app that populates the /tmp folder.
KDevelop does not leave anything there upon reboot, and cleans up despite
 being a 600lb gorilla having a big project open and many huge temp files.

Something wrong in Konsole?

Konsole was for a long time crashing upon reboot until recently.
Maybe some bugs still being worked out.
This is openSuse Tumbleweed after all, where things update daily...
I'm ready to quickly test anything you might want to try, as soon as
 it comes down the pipeline. Thanks.
Comment 6 Mariusz Glebocki 2019-10-08 23:33:46 UTC
Reverting this should help: https://invent.kde.org/kde/konsole/commit/660559600f1663e4538611870d1fcde418e55704
This code creates named file, which must be removed by working program. Unnamed files are removed by kernel automatically.

Access to unnamed files (under linux) is provided through /proc/XXX/fd/:

lrwx------ 1 mglb mglb 64 Oct  9 00:58 17 -> '/tmp/#6060213 (deleted)'
lrwx------ 1 mglb mglb 64 Oct  9 00:58 18 -> '/tmp/#6060214 (deleted)'
lrwx------ 1 mglb mglb 64 Oct  9 00:58 19 -> '/tmp/#6060215 (deleted)'

I'll test it tomorrow.
Comment 7 Tim E. Real 2019-10-09 00:36:10 UTC
Thanks for the tip. I did not know that about QTemporayFile.
It does not appear to specifically mention that in the docs.
I began using that class in our app recently.

I read a topic somewhere "How long do temporary files made with mktemp last?"
 with posts explaining in detail and mentioned checking 'TMPTIME',
 or /etc/cron.daily/tmpwatch. Both don't seem to exist here.
Comment 8 Mariusz Glebocki 2019-10-11 01:41:13 UTC
Fix:
https://invent.kde.org/kde/konsole/merge_requests/39

Should also work on systems where QTemporaryFile does not create unnamed files.
Comment 9 Kurt Hindenburg 2019-10-11 01:45:52 UTC
We could revert https://invent.kde.org/kde/konsole/commit/660559600f1663e4538611870d1fcde418e55704 - and perhaps just leave a note when debugging history files to re-add it.
Comment 10 Kurt Hindenburg 2019-10-24 01:05:53 UTC
committed in 0f19efa5b27c4f90a6195265533df1ddc214d936