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 340854 - crash (segfault) when incremental searching past song titled "Never"
crash (segfault) when incremental searching past song titled "Never"
Status: RESOLVED DUPLICATE of bug 332992
Product: rhythmbox
Classification: Other
Component: general
0.9.3
Other Linux
: Normal normal
: ---
Assigned To: RhythmBox Maintainers
RhythmBox Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-05-06 20:03 UTC by Tim
Modified: 2006-05-06 21:53 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14



Description Tim 2006-05-06 20:03:02 UTC
Distribution: Debian testing/unstable
Version: GNOME2.14.1 0.9.3
Gnome-Distributor: Debian
BugBuddy-GnomeVersion: 2.0 (2.14.1)
Description of the crash:
segfault in type_ahead_search_func due to entry->title having never been folded.

Steps to reproduce the crash:
1. Add a song whose title metadata is "Never" (exactly) to your library
2. In the library view, starting from the first song, try to incremental-search past the newly-added song (typing a number of 'z's works for me)
3. It will crash

Expected Results:
It should not crash :)

How often does this happen?
Every time (as long as you have such a song in your play list)

Additional Information:
I have not checked 0.9.4 yet. I notice 0.9.4 uses a different mechanism for accessing the folded value, but this bug could still exist.

the problem can be traced to rb-refstring.c, rb_refstring_new_full: if you pass in a string that has been both (1) referenced before, and (2) matches an internal string, then you get an RBRefString whose folded value is NULL.

The flow is basically:
1. "Never" gets _new_full()'ed internally early on, with compute_sortdata=FALSE
    thus, ret->folded and ret->sortkey = NULL.
2. "Never" gets used in a song name, with compute_sortdata=TRUE
   this function ignores compute_sortdata and returns the original "Never" string, with NULL folded and sortkey values.
3. Inc-search passes rb_refstring_get_folded(entry->title) to strstr. As you recall, title was never folded, so get_folded returns NULL, which violates strstr's interface. A crash (null pointer dereference) ensues.

If I patch rb_refstring_new_full as follows, the crash goes away.

if the string is found ('ret' test early on), and if compute_sortdata is true and the 'folded' property is null, then initialize folded and sortkey (since they weren't before) in the same was as is done a few lines down.

Basically, the problem seems to be that "strings" have identity confusion: _new_full's algorithm implies the contents of the string (the char*) wholly identify the string. However, the actual contents of the RBRefString include meta-data that may be different for two "identical" strings (the meta-data are solely performance-enhancement-related, given the code I'm looking at in 0.9.3). An example of this case is "Never", which is used both in strings that won't be searched (like "time last played") and those that will (like "song title").

Other ways to solve it:
* compute and add the metadata when it's accessed for the first time (since all accesses appear to be through functions, even in CVS HEAD).
* raise an error (or warning) when metadata is accessed that was never set (doesn't actually fix it, but helps find other occurrences).
* use some API that can gracefully accept NULL pointers in type_ahead_search_func (would cause another bug: song titles matching internal strings can't be searched for).

See also:
bug 330226 (modified the API used for getting this kind of meta-data; dated after the code in my backtrace)



Debugging Information:

Backtrace was generated from '/usr/bin/rhythmbox'

Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -1495128384 (LWP 15244)]
[New Thread -1512133712 (LWP 15246)]
[New Thread -1503741008 (LWP 15245)]
0xffffe410 in __kernel_vsyscall ()

Thread 1 (Thread -1495128384 (LWP 15244))

  • #0 __kernel_vsyscall
  • #1 __waitpid_nocancel
    from /lib/tls/i686/cmov/libpthread.so.0
  • #2 libgnomeui_module_info_get
    from /usr/lib/libgnomeui-2.so.0
  • #3 <signal handler called>
  • #4 strstr
    from /lib/tls/i686/cmov/libc.so.6
  • #5 type_ahead_search_func
    at rb-entry-view.c line 201
  • #6 gtk_tree_view_set_search_equal_func
    from /usr/lib/libgtk-x11-2.0.so.0
  • #7 gtk_tree_view_set_search_equal_func
    from /usr/lib/libgtk-x11-2.0.so.0
  • #8 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #9 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #10 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #11 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #12 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #13 gtk_entry_set_visibility
    from /usr/lib/libgtk-x11-2.0.so.0
  • #14 _gtk_marshal_VOID__STRING_INT_POINTER
    from /usr/lib/libgtk-x11-2.0.so.0
  • #15 g_cclosure_new_swap
    from /usr/lib/libgobject-2.0.so.0
  • #16 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #17 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #18 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #19 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #20 _gtk_entry_get_borders
    from /usr/lib/libgtk-x11-2.0.so.0
  • #21 gtk_editable_insert_text
    from /usr/lib/libgtk-x11-2.0.so.0
  • #22 gtk_entry_set_visibility
    from /usr/lib/libgtk-x11-2.0.so.0
  • #23 g_cclosure_marshal_VOID__STRING
    from /usr/lib/libgobject-2.0.so.0
  • #24 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #25 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #26 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #27 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #28 gtk_im_multicontext_new
    from /usr/lib/libgtk-x11-2.0.so.0
  • #29 g_cclosure_marshal_VOID__STRING
    from /usr/lib/libgobject-2.0.so.0
  • #30 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #31 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #32 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #33 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #34 gtk_im_context_simple_new
    from /usr/lib/libgtk-x11-2.0.so.0
  • #35 gtk_im_context_simple_new
    from /usr/lib/libgtk-x11-2.0.so.0
  • #36 gtk_im_context_filter_keypress
    from /usr/lib/libgtk-x11-2.0.so.0
  • #37 gtk_im_multicontext_new
    from /usr/lib/libgtk-x11-2.0.so.0
  • #38 gtk_im_context_filter_keypress
    from /usr/lib/libgtk-x11-2.0.so.0
  • #39 gtk_entry_set_visibility
    from /usr/lib/libgtk-x11-2.0.so.0
  • #40 _gtk_marshal_BOOLEAN__BOXED
    from /usr/lib/libgtk-x11-2.0.so.0
  • #41 g_cclosure_new_swap
    from /usr/lib/libgobject-2.0.so.0
  • #42 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #43 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #44 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #45 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #46 gtk_widget_activate
    from /usr/lib/libgtk-x11-2.0.so.0
  • #47 gtk_window_propagate_key_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #48 gtk_window_activate_key
    from /usr/lib/libgtk-x11-2.0.so.0
  • #49 _gtk_marshal_BOOLEAN__BOXED
    from /usr/lib/libgtk-x11-2.0.so.0
  • #50 g_cclosure_new_swap
    from /usr/lib/libgobject-2.0.so.0
  • #51 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #52 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #53 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #54 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #55 gtk_widget_activate
    from /usr/lib/libgtk-x11-2.0.so.0
  • #56 gtk_propagate_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #57 gtk_main_do_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #58 _gdk_events_queue
    from /usr/lib/libgdk-x11-2.0.so.0
  • #59 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #60 g_main_context_check
    from /usr/lib/libglib-2.0.so.0
  • #61 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #62 bonobo_main
    from /usr/lib/libbonobo-2.so.0
  • #63 main
    at main.c line 398
  • #0 __kernel_vsyscall

Comment 1 Jonathan Matthew 2006-05-06 21:53:47 UTC
The mechanism used in 0.9.4+ for creating folded and sort key forms of reference counted strings doesn't have this problem, as it creates the alternate forms the first time they are requested.

*** This bug has been marked as a duplicate of 332992 ***