After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 700507 - Segfault comparing two files when accessing smb:///
Segfault comparing two files when accessing smb:///
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: Crashers
3.16.x
Other Linux
: High critical
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-05-17 09:08 UTC by Étienne Bersac
Modified: 2015-10-20 15:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Handle nautilus_file_peek_display_name returning NULL (1.83 KB, patch)
2015-10-16 14:20 UTC, Iain Lane
needs-work Details | Review
nautilus_file_peek_display_name: Don't return NULL (883 bytes, patch)
2015-10-19 14:33 UTC, Iain Lane
none Details | Review
nautilus_file_peek_display_name: Don't return NULL (1.09 KB, patch)
2015-10-19 16:02 UTC, Iain Lane
committed Details | Review

Description Étienne Bersac 2013-05-17 09:08:23 UTC
Hi,

Using nautilus 3.8.1 from Ubuntu GNOME PPA, i get a crasher when browsing windows networks

$ nautilus --version
GNOME nautilus 3.8.1


Steps to reproduice :

 1. open nautilus
 2. Go to "Browse Networks"
 3. Go to "Windows networks"
 4. Wait a few seconds (it shows loading). Nautilus then segfaults.


Here is the backtrace. Don't hesitate to ask me some more details.

--------------------8<-----------------------
Program received signal SIGSEGV, Segmentation fault.
compare_by_display_name (file_1=0xab5980, file_2=0xab5b10) at nautilus-file.c:2907
2907    nautilus-file.c: Aucun fichier ou dossier de ce type.
(gdb) bt
  • #0 compare_by_display_name
    at nautilus-file.c line 2907
  • #1 nautilus_file_compare_for_sort
    at nautilus-file.c line 3184
  • #2 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #3 sort_files
    at nautilus-view.c line 3357
  • #4 process_new_files
    at nautilus-view.c line 3435
  • #5 done_loading_callback
    at nautilus-view.c line 3830
  • #6 ??
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #7 g_signal_emit_valist
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #8 g_signal_emit
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #9 nautilus_directory_emit_done_loading
    at nautilus-directory.c line 829
  • #10 dequeue_pending_idle_callback
    at nautilus-directory-async.c line 976
  • #11 directory_load_done
    at nautilus-directory-async.c line 1112
  • #12 more_files_callback
    at nautilus-directory-async.c line 2024
  • #13 ??
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #14 g_simple_async_result_complete
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #15 ??
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #16 g_main_context_dispatch
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #17 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #18 g_main_context_iteration
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #19 g_application_run
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #20 main
    at nautilus-main.c line 104
$1 = (NautilusFile *) 0xab5980
(gdb) p nautilus_file_dump(file1)
No symbol "file1" in current context.
(gdb) p nautilus_file_dump(file_1)
uri: smb:/// 
size: 0 
kind: unknown 
$2 = void
(gdb) p nautilus_file_dump(file_2)                                                                                                                                      
uri: smb:///NONSTOP 
size: 0 
kind: unknown 
$3 = void
(gdb) 
-------------------->8-----------------------


Regards,
Étienne BERSAC
Comment 1 Étienne Bersac 2013-05-17 09:21:26 UTC
I reproduced the bug with GNOME nautilus 3.6.3 :

Same steps.

--------------------8<-----------------------
Program received signal SIGSEGV, Segmentation fault.
compare_by_display_name (file_1=0xab17d0, file_2=0xab1320) at nautilus-file.c:2907
2907    nautilus-file.c: Aucun fichier ou dossier de ce type.
(gdb) bt
  • #0 compare_by_display_name
    at nautilus-file.c line 2907
  • #1 nautilus_file_compare_for_sort
    at nautilus-file.c line 3184
  • #2 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #3 sort_files
    at nautilus-view.c line 3368
  • #4 process_new_files
    at nautilus-view.c line 3446
  • #5 done_loading_callback
    at nautilus-view.c line 3841
  • #6 ??
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #7 g_signal_emit_valist
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #8 g_signal_emit
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #9 nautilus_directory_emit_done_loading
    at nautilus-directory.c line 833
  • #10 dequeue_pending_idle_callback
    at nautilus-directory-async.c line 989
  • #11 directory_load_done
    at nautilus-directory-async.c line 1129
  • #12 more_files_callback
    at nautilus-directory-async.c line 2113
  • #13 ??
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #14 g_simple_async_result_complete
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #15 ??
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #16 g_main_context_dispatch
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #17 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #18 g_main_context_iteration
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #19 g_application_run
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #20 main
    at nautilus-main.c line 103
uri: smb:/// 
size: 0 
kind: unknown 
[Thread 0x7fffd1895700 (LWP 3203) exited]
$1 = void
(gdb) p nautilus_file_dump(file_2)
uri: smb:///NONSTOP 
size: 0 
kind: unknown 
$2 = void
(gdb) c
Continuing.
[Thread 0x7fffd3550700 (LWP 3185) exited]
-------------------->8-----------------------

Is this a bug with gvfs ?

Regards
Comment 2 António Fernandes 2013-05-17 09:54:09 UTC
Thanks for the report and backtraces. They have some debug symbols missing (indicated by double question mark). Can you install glib debug package and retrieve the traces again? I guess the Ubuntu package is libglib2.0-0-dbg.
Comment 3 Claudio Saavedra 2015-07-29 13:54:06 UTC
Can still reproduce this:

ii  nautilus 3.14.2-1

  • #0 compare_by_display_name
    at nautilus-file.c line 2881
  • #1 nautilus_file_compare_for_sort
    at nautilus-file.c line 3144
  • #2 g_list_sort_real
    at /tmp/buildd/glib2.0-2.44.1/./glib/glist.c line 1134
  • #3 g_list_sort_real
    at /tmp/buildd/glib2.0-2.44.1/./glib/glist.c line 1180
  • #4 g_list_sort_with_data
    at /tmp/buildd/glib2.0-2.44.1/./glib/glist.c line 1250
  • #5 process_new_files
    at nautilus-view.c line 3370
  • #6 process_new_files
    at nautilus-view.c line 3448
  • #7 done_loading_callback
    at nautilus-view.c line 3841
  • #8 _g_closure_invoke_va
    at /tmp/buildd/glib2.0-2.44.1/./gobject/gclosure.c line 831
  • #9 g_signal_emit_valist
    at /tmp/buildd/glib2.0-2.44.1/./gobject/gsignal.c line 3214
  • #10 g_signal_emit
    at /tmp/buildd/glib2.0-2.44.1/./gobject/gsignal.c line 3361
  • #11 nautilus_directory_emit_done_loading
    at nautilus-directory.c line 823
  • #12 dequeue_pending_idle_callback
    at nautilus-directory-async.c line 952
  • #13 directory_load_done
    at nautilus-directory-async.c line 1088
  • #14 more_files_callback
    at nautilus-directory-async.c line 1967
  • #15 next_async_callback_wrapper
    at /tmp/buildd/glib2.0-2.44.1/./gio/gfileenumerator.c line 305
  • #16 g_simple_async_result_complete
    at /tmp/buildd/glib2.0-2.44.1/./gio/gsimpleasyncresult.c line 763
  • #17 complete_in_idle_cb
    at /tmp/buildd/glib2.0-2.44.1/./gio/gsimpleasyncresult.c line 775
  • #18 g_main_context_dispatch
    at /tmp/buildd/glib2.0-2.44.1/./glib/gmain.c line 3122
  • #19 g_main_context_dispatch
    at /tmp/buildd/glib2.0-2.44.1/./glib/gmain.c line 3737
  • #20 g_main_context_iterate
    at /tmp/buildd/glib2.0-2.44.1/./glib/gmain.c line 3808
  • #21 g_main_context_iteration
    at /tmp/buildd/glib2.0-2.44.1/./glib/gmain.c line 3869
  • #22 g_application_run
    at /tmp/buildd/glib2.0-2.44.1/./gio/gapplication.c line 2308
  • #23 main
    at nautilus-main.c line 103

Comment 4 Claudio Saavedra 2015-07-29 13:56:50 UTC
Here
	name_1 = nautilus_file_peek_display_name (file_1);

Return value is NULL, so there is a null dereference later in 

	sort_last_1 = name_1[0] == SORT_LAST_CHAR1 || name_1[0] == SORT_LAST_CHAR2;
Comment 5 sandlst 2015-09-16 14:41:14 UTC
At work we have 1 domain and 1 workgoup.  For some reason in linux a third workgroup/domain shows up but the display name is blank.  

Bypassing the compare_by_display_name fuction by just forcing it to return -1 stops the crash and allows our 2 "real" workgroups/domains to be browsed without any issue (there is a timeout when connecting to the blank one).

The blank one has no name but when selected in nautilus shows "(null)" selected in the bottom right corner of the window.

Kde shows 3 separate domains/workgroups as well including the blank one.

This behavior is on nautilus 3.16.2
Comment 6 Sebastien Bacher 2015-10-09 16:27:58 UTC
Downstream reports

https://bugzilla.redhat.com/show_bug.cgi?id=1241679
https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1297533

Backtrace from 3.16.2

"#0  compare_by_display_name (file_1=0x2b64c50, file_2=0x2b64df0) at nautilus-file.c:2881
        name_1 = 0x0
        name_2 = 0x2ac8a04 "ALBA"
        sort_last_1 = <optimized out>
        sort_last_2 = <optimized out>
        compare = <optimized out>
  • #1 nautilus_file_compare_for_sort
    at nautilus-file.c line 3144
  • #2 g_list_sort_merge
    at glist.c line 1134
  • #3 g_list_sort_real
    at glist.c line 1180
  • #4 g_list_sort_with_data
    at glist.c line 1250
  • #5 sort_files
    at nautilus-view.c line 2929
  • #6 process_new_files
    at nautilus-view.c line 3007
  • #7 done_loading_callback
    at nautilus-view.c line 3397
  • #8 _g_closure_invoke_va
    at gclosure.c line 831
  • #9 g_signal_emit_valist
    at gsignal.c line 3214
  • #10 g_signal_emit
    at gsignal.c line 3361
  • #11 nautilus_directory_emit_done_loading
    at nautilus-directory.c line 818
  • #12 dequeue_pending_idle_callback
    at nautilus-directory-async.c line 952
  • #13 directory_load_done
    at nautilus-directory-async.c line 1088
  • #14 more_files_callback
    at nautilus-directory-async.c line 1967
  • #15 next_async_callback_wrapper
    at gfileenumerator.c line 305
  • #16 g_simple_async_result_complete
    at gsimpleasyncresult.c line 763
  • #17 complete_in_idle_cb
    at gsimpleasyncresult.c line 775
  • #18 g_main_dispatch
    at gmain.c line 3122
  • #19 g_main_context_dispatch
    at gmain.c line 3737
  • #20 g_main_context_iterate
    at gmain.c line 3808
  • #21 g_main_loop_run
    at gmain.c line 4002
  • #22 gtk_dialog_run
    at gtkdialog.c line 1393
  • #23 do_run_simple_dialog
    at nautilus-file-operations.c line 1110
  • #24 mainloop_proxy_func
    at gioscheduler.c line 200
  • #25 g_main_dispatch
    at gmain.c line 3122
  • #26 g_main_context_dispatch
    at gmain.c line 3737
  • #27 g_main_context_iterate
    at gmain.c line 3808
  • #28 g_main_context_iteration
    at gmain.c line 3869
  • #29 g_application_run
    at gapplication.c line 2308
  • #30 main
    at nautilus-main.c line 103


The previous comment have a description of the issue in the code and seems to be due to smb entries with a blank name
Comment 7 Sebastien Bacher 2015-10-09 16:32:55 UTC
https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1280867 has some useful hint of on the cases leading to the issue

"If one of the Ubuntu clients has a hostname that is too long to be automatically converted to a NetBIOS name, it shows up in the smbtree -N output with a blank NetBIOS name. Example:

\\ really-long-name-of-computer server (Samba, Ubuntu)

This blank name is what causes this bug in nautilus. If I go into the offending machines and give them a custom short NetBIOS name in /etc/samba/smb.conf, and restart nmbd on them, the problem goes away and I can browse the Windows network just fine. Perhaps compare_by_display_name() is not handling a NULL or empty string correctly? Either way, it looks like nmbd is auto-generating an empty name, so I would argue that it has a bug that is indirectly causing this bug at the same time."
Comment 8 Sebastien Bacher 2015-10-09 16:42:01 UTC
The empty name seems to be a samba bug resolve upstream, see https://bugzilla.samba.org/show_bug.cgi?id=10896, it's probably going to take a while before the servers out there get a fixed samba so it would still be better if nautilus handling the empty name with segfaulting
Comment 9 Iain Lane 2015-10-16 14:20:27 UTC
Created attachment 313468 [details] [review]
Handle nautilus_file_peek_display_name returning NULL
Comment 10 Carlos Soriano 2015-10-19 14:08:33 UTC
Review of attachment 313468 [details] [review]:

peek_display_name already have checks for NULL display_names and it returns "" or it validates etc. What is not working there? And anyway, I think you just need to manage the special case there and not elsewhere in the code, because then any other client of peek_display_name will have the same non-obvious problem of display_name being NULL and got_custom_display_name being FALSE, which is against the invariant.
Comment 11 Iain Lane 2015-10-19 14:33:32 UTC
Created attachment 313666 [details] [review]
nautilus_file_peek_display_name: Don't return NULL
Comment 12 Iain Lane 2015-10-19 14:36:33 UTC
There's a case where nautilus_file_set_display_name might not set the name, if it hits this.

    if (display_name == NULL || *display_name == 0) {
        return FALSE;
    }

Are you asking for something like that? ^ (untested - I lost my way to reproduce this bug)
Comment 13 Carlos Soriano 2015-10-19 15:32:48 UTC
(In reply to Iain Lane from comment #12)
> There's a case where nautilus_file_set_display_name might not set the name,
> if it hits this.
> 
>     if (display_name == NULL || *display_name == 0) {
>         return FALSE;
>     }
> 
ah right, just realized "" == *text == 0 .
Comment 14 Carlos Soriano 2015-10-19 15:36:08 UTC
Review of attachment 313666 [details] [review]:

indeed, that was my suggestion.
Can you do it even simpler?:

return name ? eel_ref_str_peek (name) : "";

Also, can you provide a commit message explaining this issue?
Comment 15 Carlos Soriano 2015-10-19 15:44:47 UTC
> 
> return name ? eel_ref_str_peek (name) : "";
I meant:
return  file->details->display_name ? eel_ref_str_peek ( file->details->display_name) : "";
Comment 16 Iain Lane 2015-10-19 16:02:00 UTC
Created attachment 313675 [details] [review]
nautilus_file_peek_display_name: Don't return NULL

If the name is the empty string then nautilus_file_set_display_name
won't actually set the display name. In this case we were returning
NULL from nautilus_file_peek_display_name, which some of our callers
weren't prepared to handle. This led to crashes.
Comment 17 Carlos Soriano 2015-10-19 19:58:19 UTC
Review of attachment 313675 [details] [review]:

Perfect, thanks!
Comment 18 Iain Lane 2015-10-20 15:14:08 UTC
Attachment 313675 [details] pushed as 3fb7cff - nautilus_file_peek_display_name: Don't return NULL