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 773400 - rhythmbox crashed with SIGSEGV when playing remote DMAP missing track.
rhythmbox crashed with SIGSEGV when playing remote DMAP missing track.
Status: RESOLVED FIXED
Product: libdmapsharing
Classification: Other
Component: DAAP Server
git master
Other Linux
: Normal normal
: ---
Assigned To: W. Michael Petullo
W. Michael Petullo
Depends on:
Blocks:
 
 
Reported: 2016-10-24 06:27 UTC by gnome.vrb
Modified: 2016-11-12 02:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do not transmit unplayable rhythmdb entries to the DMAP client (1.16 KB, patch)
2016-10-24 06:31 UTC, gnome.vrb
none Details | Review

Description gnome.vrb 2016-10-24 06:27:10 UTC
gdb) bt
  • #0 g_input_stream_close
    at ././gio/ginputstream.c line 495
  • #1 0x00007fc598adef21 in
  • #2 _dmap_share_databases
  • #3 got_body
    at soup-server.c line 1261
  • #4 got_body
    at soup-server.c line 1402
  • #8 <emit signal ??? on instance 0x559b66c84480 [SoupMessage]>
    at ././gobject/gsignal.c line 3447
  • #9 soup_message_got_body
    at soup-message.c line 1140
  • #10 io_read
    at soup-message-io.c line 786
  • #11 io_run_until
    at soup-message-io.c line 982
  • #12 io_run
    at soup-message-io.c line 1053
  • #13 soup_message_io_server
    at soup-message-io.c line 1257
  • #14 soup_message_read_request
    at soup-message-server-io.c line 304
  • #15 g_cclosure_marshal_VOID__OBJECTv
    at ././gobject/gmarshal.c line 2102
  • #16 _g_closure_invoke_va
    at ././gobject/gclosure.c line 867
  • #17 g_signal_emit_valist
    at ././gobject/gsignal.c line 3300
  • #18 g_signal_emit
    at ././gobject/gsignal.c line 3447
  • #19 listen_watch
    at soup-socket.c line 1220
  • #20 g_main_context_dispatch
    at ././glib/gmain.c line 3203
  • #21 g_main_context_dispatch
    at ././glib/gmain.c line 3856
  • #22 g_main_context_iterate
    at ././glib/gmain.c line 3929
  • #23 g_main_context_iteration
    at ././glib/gmain.c line 3990
  • #24 g_application_run
    at ././gio/gapplication.c line 2381
  • #25 rb_application_run
    at rb-application.c line 667
  • #26 main
    at main.c line 88

Comment 1 gnome.vrb 2016-10-24 06:31:09 UTC
Created attachment 338316 [details] [review]
Do not transmit unplayable rhythmdb entries to the DMAP client
Comment 2 gnome.vrb 2016-10-24 08:27:13 UTC
Same trace in description, with "libdmapsharing" debug symbols installed.

Thread 1 (Thread 0x7fc5c44f14c0 (LWP 25393))

  • #0 g_input_stream_close
    at ././gio/ginputstream.c line 495
  • #1 databases_items_xxx
    at daap-share.c line 522
  • #2 databases_items_xxx
    at daap-share.c line 942
  • #3 _dmap_share_databases
    at dmap-share.c line 2061
  • #4 got_body
    at soup-server.c line 1261
  • #5 got_body
    at soup-server.c line 1402
  • #9 <emit signal ??? on instance 0x559b66c84480 [SoupMessage]>
    at ././gobject/gsignal.c line 3447
  • #10 soup_message_got_body
    at soup-message.c line 1140
  • #11 io_read
    at soup-message-io.c line 786
  • #12 io_run_until
    at soup-message-io.c line 982
  • #13 io_run
    at soup-message-io.c line 1053
  • #14 soup_message_io_server
    at soup-message-io.c line 1257
  • #15 soup_message_read_request
    at soup-message-server-io.c line 304
  • #16 g_cclosure_marshal_VOID__OBJECTv
    at ././gobject/gmarshal.c line 2102
  • #17 _g_closure_invoke_va
    at ././gobject/gclosure.c line 867
  • #18 g_signal_emit_valist
    at ././gobject/gsignal.c line 3300
  • #19 g_signal_emit
    at ././gobject/gsignal.c line 3447
  • #20 listen_watch
    at soup-socket.c line 1220
  • #21 g_main_context_dispatch
    at ././glib/gmain.c line 3203
  • #22 g_main_context_dispatch
    at ././glib/gmain.c line 3856
  • #23 g_main_context_iterate
    at ././glib/gmain.c line 3929
  • #24 g_main_context_iteration
    at ././glib/gmain.c line 3990
  • #25 g_application_run
    at ././gio/gapplication.c line 2381
  • #26 rb_application_run
    at rb-application.c line 652
  • #27 main
    at main.c line 88

Comment 3 Jonathan Matthew 2016-10-24 10:21:09 UTC
The crash is caused by an uninitialized pointer deref in libdmapsharing, so I'm reassigning the bug.  The rhythmbox patch should go in a new bug since it's not really related to the crash at all.
Comment 4 Jonathan Matthew 2016-10-24 10:23:24 UTC
https://git.gnome.org/browse/libdmapsharing/tree/libdmapsharing/daap-share.c#n418
- this should probably be g_new0.
Comment 5 gnome.vrb 2016-10-25 10:08:42 UTC
(In reply to Jonathan Matthew from comment #3)
> The crash is caused by an uninitialized pointer deref in libdmapsharing, so
> I'm reassigning the bug.  The rhythmbox patch should go in a new bug since
> it's not really related to the crash at all.

Created https://bugzilla.gnome.org/show_bug.cgi?id=773466
Comment 6 gnome.vrb 2016-10-25 10:30:03 UTC
(In reply to Jonathan Matthew from comment #4)
> https://git.gnome.org/browse/libdmapsharing/tree/libdmapsharing/daap-share.
> c#n418
> - this should probably be g_new0.

That seems to fix the crash.

FWIW, "g_new" might need to be revisited in the following places too.

dev@unstable:~/source/apt/libdmapsharing/libdmapsharing-2.9.36$ grep "\<g_new\>" -R . 2>/dev/null
./libdmapsharing/dmap-mdns-browser-dnssd.c:	service = g_new (DMAPMdnsBrowserService, 1);
./libdmapsharing/dmap-share.c:		share_bitwise = g_new (struct share_bitwise_t, 1);
./libdmapsharing/dpap-share.c:	ChunkData *cd = g_new (ChunkData, 1);
./libdmapsharing/dmap-mdns-browser-howl.c:	service = g_new (DMAPMdnsBrowserService, 1);
./libdmapsharing/dacp-share.c:	remote_info = g_new (DACPRemoteInfo, 1);
./libdmapsharing/daap-share.c:	cd = g_new (ChunkData, 1);
./libdmapsharing/dmap-mdns-browser-avahi.c:		service = g_new (DMAPMdnsBrowserService, 1);
./libdmapsharing/dmap-mdns-publisher-avahi.c:	service = g_new (struct DMAPMdnsPublisherService, 1);
./libdmapsharing/dmap-connection.c:	rdata = g_new (ConnectionResponseData, 1);
./libdmapsharing/dmap-connection.c:	rdata = g_new (ConnectionResponseData, 1);
Comment 7 W. Michael Petullo 2016-11-12 01:53:50 UTC
I decided to consistently use g_new0, even though it appeared that libdmapsharing was initializing each field in these structures after the allocation. It did appear that the structure referenced in comment #4 had each of its fields initialized too, so I am not sure the lack of g_new0 there was a problem. Can someone show otherwise?

Using g_new0 is safer in case we add a field to one of the structures in the future.
Comment 8 Jonathan Matthew 2016-11-12 02:04:38 UTC
in the error case here:

        stream = G_INPUT_STREAM (daap_record_read (record, &error));
        if (error != NULL) {
                g_warning ("Couldn't open %s: %s.", location, error->message);
                goto _error;
        }

cd->stream is not initialised before we reach _error:

_error:
        soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);

        if (NULL != cd) {
                if (NULL != cd->stream) {
                        g_input_stream_close (cd->stream, NULL, NULL);
                }

                g_free (cd);
        }

so it can be non-NULL and also not a valid GInputStream pointer (probably not a valid address at all), which will cause g_input_stream_close to crash.
Comment 9 W. Michael Petullo 2016-11-12 02:41:15 UTC
Got it. The use of g_new0 should have fixed this. Please see 2.9.37.