Crash when reloading an active search with F5
Summary
Thunar sometimes segfaults when an active search is reloaded with F5. The crash is reproducible with the packaged Thunar 4.20.9-1 on EndeavourOS, although not on every attempt.
Environment
- Thunar 4.20.9-1
- Xfce 4.20
- GTK 3.24.52
- GLib 2.88.3
- EndeavourOS / Arch Linux, x86_64
Steps to reproduce
- Open a directory containing several files, including
.mp4files. - Press Ctrl+F and search for
.mp4. - Optionally click in the file view to defocus the search field.
- Press F5 repeatedly while the search is active.
The same behavior can occur in other directories and with the search field focused.
Expected behavior
The search results should be refreshed, or the search should be cleared consistently according to the intended UI behavior. Thunar should not crash.
Actual behavior
Thunar occasionally terminates with:
Segmentation fault (core dumped)The symbolized backtrace reaches:
thunar_util_search_terms_match()
_thunar_tree_view_model_matches_search_terms()
_thunar_tree_view_model_search_file_changed()
thunar_file_changed()
thunar_file_reload()
thunar_folder_finished()The failing callback can run after the tree model root has been cleared during deferred cleanup. The file-watch callbacks remain connected until node destruction, so a file change can reach the search callback while its model is being torn down.
I have reproduced the crash with an isolated build of the unmodified 4.20.9 source and verified a one-file fix that disconnects the file watchers before deferred node cleanup begins. I will submit that fix in a merge request after this issue is recorded.
Investigation and patch drafting were AI-assisted; the contributor reviewed the code and verified the behavior locally.
Version information
Steps to reproduce
- ...
- ...
- ...