Summary: | Qt Applications crash with SIGBUS if XDG_CACHE_HOME directory is too small (or maybe out of space) | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kcoreaddons | Reporter: | Mike <bugs> |
Component: | general | Assignee: | Michael Pyne <mpyne> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | alexey.min, kdelibs-bugs |
Priority: | NOR | ||
Version: | 5.51.0 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://commits.kde.org/kcoreaddons/eb916c305a5cd8683e7e8f955740a7c810220e19 | Version Fixed In: | |
Sentry Crash Report: |
Description
Mike
2018-11-03 04:05:46 UTC
I can reproduce this in Neon dev-unstable 18.04 (crashes every second run, or prints "Unable to acquire shared lock, is the cache corrupt?"). Proposed fix: https://phabricator.kde.org/D16744 Git commit eb916c305a5cd8683e7e8f955740a7c810220e19 by Alexey Min. Committed on 07/11/2018 at 23:33. Pushed by alexeymin into branch 'master'. Fix crash if XDG_CACHE_HOME directory is too small or out of space Summary: Incorrect checking for error return code of posix_fallocate() causes function to think that everything is OK, while it is not, causing crash in some cases. Related: bug 339829 Test Plan: good test plan provided in https://bugs.kde.org/show_bug.cgi?id=400610 . Works like a charm, tested in KDE Neon dev-ustable The reason for bug was that return value of posix_fallocate() was assumed to be negative on error, but in fact it is a positive integer. The check was `< 0`, whi should be `!= 0`. ( http://man7.org/linux/man-pages/man3/posix_fallocate.3.html ) With this fix applied test application does not crash, and the output in console widow is: ``` No space left on device. Check filesystem free space at your XDG_CACHE_HOME! The operating system is unable to promise 10547304 bytes for mapped cache, abandoning the cache for crash-safety. org.kde.kcoreaddons: Failed to establish shared memory mapping, will fallback to private memory -- memory usage will increase ``` Reviewers: dfaure, #frameworks, mpyne Reviewed By: dfaure Subscribers: cfeck, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D16744 M +4 -1 src/lib/caching/kshareddatacache_p.h https://commits.kde.org/kcoreaddons/eb916c305a5cd8683e7e8f955740a7c810220e19 @Alexey Min: thanks for fixing this bug so quickly! :-) For the sake of completeness: I found a very similar problem in Qt (same test program, missing test before mmap()): https://bugreports.qt.io/browse/QTQAINFRA-2381 |