Bug 477298 - Dolphin hangs when navigating to a directory with any JSON files in it
Summary: Dolphin hangs when navigating to a directory with any JSON files in it
Status: CONFIRMED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 23.08.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-20 20:17 UTC by Ilya Bizyaev
Modified: 2024-06-05 11:42 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Bizyaev 2023-11-20 20:17:33 UTC
SUMMARY
For me, this started today after an update. Dolphin displays a blank view for the folder and then gets stuck indefinitely until being killed by the user.

STEPS TO REPRODUCE
1. mkdir tmp
2. touch tmp/test2.json
3. Navigate to ./tmp

OBSERVED RESULT
Dolphin hangs

EXPECTED RESULT
Dolphin opens the folder

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20231117
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.112.0
Qt Version: 5.15.11
Kernel Version: 6.6.1-1-default (64-bit)
Graphics Platform: Wayland
Graphics Processor: Mesa Intel® UHD Graphics

ADDITIONAL INFORMATION

I suspect that Dolphin hangs somewhere in thumbnail generation or metadata extraction code, as even hovering a JSON file path in the terminal panel is enough to trigger the bug. However, I have "Text document" thumbnails disabled, and even disabling thumbnails completely doesn't make the problem disappear.
Comment 1 fanzhuyifan 2023-11-21 18:48:08 UTC
Can't reproduce in KDE neon unstable. Maybe it is fixed in plasma 6?
Comment 2 Metz 2023-11-29 23:24:54 UTC
I can confirm this behaviour. Not only freezes it Dolphin, it also causes a massive memory leak eating all system resources until it is unresponsive and then crashes the program. 

It is enough to have a .json file in a folder. No matter if it has content. Even a simple empty test.json triggers the bug.

SOFTWARE/OS VERSIONS
Operating System: Manjaro 
KDE Plasma Version: 5.27.9-1
KDE Frameworks Version: 5.112.0-1
Qt Version: 5.15.11+kde+r147-1
Kernel Version: 6.6.3-1-MANJARO
Graphics Platform: Wayland
Graphics Processor: Navi 32 [Radeon RX 7700 XT / 7800 XT]
Comment 3 Ilya Bizyaev 2023-11-30 01:21:56 UTC
The problem is somewhere in Frameworks. Other ways to reproduce:
* Hover over a JSON filename in Konsole so it tries to display a preview
* Download a JSON file with Firefox with plasma-browser-integration so Plasma tries to display a notification about the JSON file
* kioclient5 stat test.json
Comment 4 Ilya Bizyaev 2023-11-30 16:05:56 UTC
I can reproduce this problem with kioclient from Plasma 6 (built with kdesrc-build), so this also affects KF6.
Comment 5 Metz 2023-12-01 10:42:15 UTC
I thought as well disabling previews / thumbnails would help since it looked like it was kioslave5 `thumbnail.so` that was eating extreme amounts of memory and taking everything down. however, now instead of only the folders with a .json in it not working, now no folder works and right now i basically completely lost access to dolphin.

however, for testing i created a second user on my system and after login i noticed everything works perfectly fine. no problems with dolphin whatsoever. which i tbh can not really explain since obviously both accounts use the same software versions. so the only difference can be in the configuration of those, but the only change on the main account between working and non-working state was the installation of "appimagelauncher" which brings libappimage and squashfuse with it. since the first is used by `kio-extras` to handle appimage thumbnails it is imho a suspect. but removing it did not fix it.

and i'm unable to reproduce the problem on a second account so i'm at a loss here what caused it. the last major system update was 22. November, 6 days before i started to notice problems, so as a daily user i have a hard time believing it was caused by something there. it is however consistent with OPs report date. the only other update inbetween, 3 days before the problems was lib32-libxml2, libxml2 and mawk.

i also run mesa-git which updates daily. which i thought may be a factor. but downgrading to stable (1.23.1.9) had no effect.
Comment 6 Ilya Bizyaev 2023-12-06 18:54:16 UTC
So I've debugged this problem, and it is caused by an infinite loop in `QMimeDatabasePrivate::inherits`. The reason is that this method doesn't handle parent-child cycles: for some reason, in my `~/.local/share/mime/` (I didn't even know this directory existed), "application/javascript" was declared a subclass of "application/ecmascript". Normally (`usr/share/mime/packages/freedesktop.org.xml`), it's the other way around, so the combined info created a cycle.

Now, I don't know what the solution for this is:
* Should Qt learn to handle such cycles? Even if they are maybe not allowed by the spec, getting stuck in an infinite loop with infinite allocations because of a file that users have no knowledge of is not great.
* Why was this edge declared in `~/.local/share/mime/` in the first place? Since I've never edited anything in this directory myself, I guess it had been created automatically, so whatever did it can do it again in the future.
* Why has this bug never occurred before 20.11.23?

Anyway, as a workaround, I deleted `~/.local/share/mime/`, and the issue if gone for now.
Comment 7 Ilya Bizyaev 2023-12-06 19:04:13 UTC
Oh, I've just figured out the "why now": https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/275

I guess my `~/.local/share/mime/` retained a copy the old declaration, which caused the cycle. So the update of shared-mime-info to 2.4, which I installed on the 20th of November, is the trigger.

I'll CC dfaure because he's involved in both projects :)
Comment 8 Jarrod Farrell 2024-01-08 21:26:32 UTC
I seem to be encountering this same issue. However, removing my `~/.local/share/mime` didn't rectify the issue as it did for Ilya Bizyaev. Did they run a command after removing that folder? Also checking the copy of the bugged folder there's no reference to application/json or application/ecmascript.

My Dolphin version is 23.08.4

# OS information:
Operating System: NixOS 24.05
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.112.0
Qt Version: 5.15.11
Kernel Version: 6.1.71 (64-bit)
Graphics Platform: Wayland
Comment 9 Jarrod Farrell 2024-01-08 21:57:25 UTC
More sleuthing with strace against `systemsettings kcm_filetypes` since even trying to change the associations for `json` causes settings to hang:
```
[...clicking around, navigating to json...]
readlink("/nix/store/nszw28wv32h9qr2nric9f5f89v7a2cx0-ark-23.08.4/lib/qt-5.15.11/plugins/kf5/parts", 0x7ffeacb63890, 1023) = -1 EINVAL (Invalid argument)
readlink("/nix/store/nszw28wv32h9qr2nric9f5f89v7a2cx0-ark-23.08.4/lib/qt-5.15.11/plugins/kf5/parts/arkpart.so", 0x7ffeacb63890, 1023) = -1 EINVAL (Invalid argument)
openat(AT_FDCWD, "/nix/store/nszw28wv32h9qr2nric9f5f89v7a2cx0-ark-23.08.4/lib/qt-5.15.11/plugins/kf5/parts/arkpart.so", O_RDONLY|O_CLOEXEC) = 26
statx(26, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0555, stx_size=511080, ...}) = 0
statx(26, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0555, stx_size=511080, ...}) = 0
mmap(NULL, 511080, PROT_READ, MAP_SHARED, 26, 0) = 0x7fb5cb183000
close(26)                               = 0
munmap(0x7fb5cb183000, 511080)          = 0
brk(0x4370000)                          = 0x4370000
brk(0x43c9000)                          = 0x43c9000
brk(0x43ea000)                          = 0x43ea000
brk(0x440b000)                          = 0x440b000
[...repeats indefinitely...]
```
And watching the strace when I was clicking on other associations, only `json` casued a large chain of going through all of Nix's stores to collect `kde-mimeapps.list` or `mimeapps.list` before rummaging into `/run/current-system/sw/lib/qt-5.15.11/plugins/kf5/parts` which led to following the link to reach `/nix/store/nszw28wv32h9qr2nric9f5f89v7a2cx0-ark-23.08.4/lib/qt-5.15.11/plugins/kf5/parts/arkpart.so` like we see here.
Comment 10 Akseli Lahtinen 2024-01-12 09:27:18 UTC
Can't reproduce on Plasma 6, dolphin 24.01.90
Comment 11 Ilya Bizyaev 2024-01-12 14:00:53 UTC
Have you read the comments and replicated the setup before attempting to reproduce?
Comment 12 Jarrod Farrell 2024-01-12 17:43:58 UTC
@Ilya @Akseli
It seems to be what Ilya found which was a bad mime configuration introduced by an update, but for me removing it didn't rectify the issue. And as mentioned, I didn't even have any references to json which made it even weirder. For the sake of time since I do depend on my desktop for work I ended up lifting my user directory out, create an empty user directory, and copy the folders I needed over which got Dolphin, and friends, to stop hanging after dealing with a few confused programs.

Of course it merely hides the problem, but the only folders didn't move that are not application specific are `.cache` and `.local`. I'll have to do some binary testing Later™ to scope down the issue when I have the time, though anyone else is free to take the torch since I have a few things pulling for my attention.
Comment 13 Thomas.Meschede 2024-02-26 08:16:55 UTC
(In reply to Jarrod Farrell from comment #12)
> @Ilya @Akseli
> It seems to be what Ilya found which was a bad mime configuration introduced
> by an update, but for me removing it didn't rectify the issue. And as
> mentioned, I didn't even have any references to json which made it even
> weirder. For the sake of time since I do depend on my desktop for work I
> ended up lifting my user directory out, create an empty user directory, and
> copy the folders I needed over which got Dolphin, and friends, to stop
> hanging after dealing with a few confused programs.
> 
> Of course it merely hides the problem, but the only folders didn't move that
> are not application specific are `.cache` and `.local`. I'll have to do some
> binary testing Later™ to scope down the issue when I have the time, though
> anyone else is free to take the torch since I have a few things pulling for
> my attention.

Check out this issue. They are probably related. 

https://github.com/nix-community/home-manager/issues/4941
Comment 14 Giuseppe 2024-06-03 20:54:03 UTC
The problem persists, even in a more updated PC with a different OS.

SUMMARY
Dolphin freezes, then crashes, when browsing the file system it enters a folder that contains files with the extension .json

STEPS TO REPRODUCE
1. In a terminal, create in any subfolder of the home a empty file and rename it with .json extension.
2. Open Dolphin and browse to the above folder. 

OBSERVED RESULT
Dolphin should freeze and you will have to kill it.

EXPECTED RESULT
Other file manager like Gnome "Files" enter normally in the folder

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 24.04
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13
Kernel Version: 6.8.0-31-generic (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-2400 CPU @ 3.10GHz
Memory: 15.5 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 2000
Manufacturer: Hewlett-Packard
Product Name: HP Elite 7300 Series MT
System Version: 1.01