Crash when searching while performing concurrent file renames
Description
I noticed this bug while retesting #1321 (closed).
Steps to reproduce
mkdir crash
touch crash/testtttttttttttttttttttttttttttttttttttttttttttttttttttttttttA
thunar crash
- In a terminal, run this script from the
crash
directorywhile [ 1 ] ; do mv testtttttttttttttttttttttttttttttttttttttttttttttttttttttttttA testtttttttttttttttttttttttttttttttttttttttttttttttttttttttttB; mv testtttttttttttttttttttttttttttttttttttttttttttttttttttttttttB testtttttttttttttttttttttttttttttttttttttttttttttttttttttttttA; done
- Ctrl + f in the Thunar window
- Keep typing and deleting t characters until you get the following warning and a crash:
(thunar-tree-view-model.c:2251):thunar_tree_view_model_dir_remove_file: code should not be reached
Debugging
The crash occurs when thunar_file_get_display_name
returns NULL in _thunar_tree_view_model_matches_search_terms
:
2946 static gboolean
2947 _thunar_tree_view_model_matches_search_terms (ThunarTreeViewModel *model,
2948 ThunarFile *file)
2949 {
2950 gboolean matched;
2951 gchar *name_n;
2952
2953 name_n = (gchar *) thunar_file_get_display_name (file);
2954 name_n = thunar_g_utf8_normalize_for_search (name_n, TRUE, TRUE);
#2 0x0000555555de81e5 in _thunar_tree_view_model_matches_search_terms (model=0x50e000055700, file=0x51100074b980) at thunar-tree-view-model.c:2954
(gdb) p name_n
$2 = (gchar *) 0x0
This leads to a NULL pointer dereference:
Thread 1 "thunar" received signal SIGSEGV, Segmentation fault.
g_utf8_validate (str=0x0, max_len=-1, end=0x0) at ../glib/glib/gutf8.c:1755
(gdb) bt
#0 g_utf8_validate (str=0x0, max_len=-1, end=0x0) at ../glib/glib/gutf8.c:1755
#1 0x0000555555ba8f91 in thunar_g_utf8_normalize_for_search (str=0x0, strip_diacritics=1, casefold=1) at thunar-gobject-extensions.c:210
#2 0x0000555555de81e5 in _thunar_tree_view_model_matches_search_terms (model=0x50e000055700, file=0x51100074b980) at thunar-tree-view-model.c:2954
#3 0x0000555555de6910 in thunar_tree_view_model_update_search_files (model=0x50e000055700) at thunar-tree-view-model.c:3011
#4 0x0000555555de621b in _thunar_tree_view_model_search_finished (job=0x50e000577700, model=0x50e000055700) at thunar-tree-view-model.c:1624
#5 0x00007ffff7a416c0 in g_closure_invoke (closure=0x50700079fde0, return_value=0x0, n_param_values=1, param_values=0x7fffffffdf30, invocation_hint=0x7fffffffde80)
at ../glib/gobject/gclosure.c:832
#6 0x00007ffff7a6fa36 in signal_emit_unlocked_R.isra.0
(node=node@entry=0x7fffffffe000, detail=detail@entry=0, instance=instance@entry=0x50e000577700, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffdf30) at ../glib/gobject/gsignal.c:3980
#7 0x00007ffff7a60a42 in signal_emit_valist_unlocked (instance=instance@entry=0x50e000577700, signal_id=signal_id@entry=449, detail=detail@entry=0, var_args=var_args@entry=0x7fffffffe160)
at ../glib/gobject/gsignal.c:3612
#8 0x00007ffff7a60c77 in g_signal_emit_valist (instance=0x50e000577700, signal_id=449, detail=0, var_args=var_args@entry=0x7fffffffe160) at ../glib/gobject/gsignal.c:3355
#9 0x00007ffff7a60d34 in g_signal_emit (instance=instance@entry=0x50e000577700, signal_id=<optimized out>, detail=detail@entry=0) at ../glib/gobject/gsignal.c:3675
#10 0x00007ffff7f47c90 in exo_job_finished (job=<optimized out>) at exo-job.c:437
#11 exo_job_async_ready (user_data=0x50e000577700) at exo-job.c:274
#12 exo_job_async_ready (user_data=0x50e000577700) at exo-job.c:255
#13 0x00007ffff6f34f69 in g_main_dispatch (context=0x50f000000310) at ../glib/glib/gmain.c:3476
#14 0x00007ffff6f933a7 in g_main_context_dispatch_unlocked (context=0x50f000000310) at ../glib/glib/gmain.c:4284
#15 g_main_context_iterate_unlocked.isra.0 (context=context@entry=0x50f000000310, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/glib/gmain.c:4349
#16 0x00007ffff6f33162 in g_main_context_iteration (context=context@entry=0x50f000000310, may_block=may_block@entry=1) at ../glib/glib/gmain.c:4414
#17 0x00007ffff7106b66 in g_application_run (application=0x514000000930, argc=<optimized out>, argv=0x7fffffffe5e8) at ../glib/gio/gapplication.c:2577
#18 0x0000555555a63c0c in main (argc=1, argv=0x7fffffffe5e8) at main.c:86
Version: 939876ab