Re: Segmentation Fault

voice <[email protected]> Sun, 2 Oct 2016 16:57:58 -0500
Newsgroups gmane.comp.audio.icecast.devel
Message-ID <CAExdBCtRNxJAo9P6rwf1tYosQuzN8SbgEcS3utUsEFSm4Jyymw@mail.gmail.com>
Did a little more digging on this and found that source_real wasn't being
checked to see if it was null or not. The attached patch seems to be
holding up so far on my server.

On Sat, Oct 1, 2016 at 7:55 PM, voice <[email protected]> wrote:

> Hello,
>
> I have a Icecast server, source code pulled from git, that constantly
> segfaults when the playlist stats start populating. I ran GDB on it and got
> this
>
> Program received signal SIGSEGV, Segmentation fault.
> _dump_stats_to_doc (hidden=0, show_mount=0x0, root=0x676e50) at stats.c:881
> 881            history = playlist_render_xspf(source_real->history);
>
>
> which falls in line with
>
> [24699945.204767] icecast[23864]: segfault at 118 ip 0000000000414be5 sp
> 00007ffe8ace7050 error 4 in icecast[400000+3c000]
> addr2line -e /path/to/icecast 0000000000414be5
> /path/to/icecast_git/icecast-server/src/stats.c:881
>
> OS: Debian Jessie
> Current Git commit: 72075d0d0dd97c54d2317b325bfec55a7d496f82
>

_______________________________________________
Icecast-dev mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/icecast-dev
source_real.patch (text/x-patch, 1.8 KB)
diff --git a/src/stats.c b/src/stats.c
index a77d82b..801176b 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -878,13 +878,23 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
 
             avl_tree_rlock(global.source_tree);
             source_real = source_find_mount_raw(source->source);
-            history = playlist_render_xspf(source_real->history);
-            if (history)
-                xmlAddChild(xmlnode, history);
-            metadata = xmlNewTextChild(xmlnode, NULL, XMLSTR("metadata"), NULL);
-            if (source_real->format) {
-                for (i = 0; i < source_real->format->vc.comments; i++)
-                    __add_metadata(metadata, source_real->format->vc.user_comments[i]);
+            if (source_real) {
+               history = playlist_render_xspf(source_real->history);
+               if (history)
+                   xmlAddChild(xmlnode, history);
+               metadata = xmlNewTextChild(xmlnode, NULL, XMLSTR("metadata"), NULL);
+               if (source_real->format) {
+                   for (i = 0; i < source_real->format->vc.comments; i++)
+                      if(source_real->format->vc.user_comments[i] && strlen(source_real->format->vc.user_comments[i])) {
+                         __add_metadata(metadata, source_real->format->vc.user_comments[i]);
+                        // printf("DEBUG: Adding to metadata: %s\n",source_real->format->vc.user_comments[i]);
+                      } else {
+                         __add_metadata(metadata, "Empty");
+                        // printf("DEBUG: user_comments is blank, adding to metadata: Empty\n");
+                      }
+               }
+            } else {
+               printf("DEBUG: source_real did not return true. History and Metadata skipped.\n");
             }
             avl_tree_unlock(global.source_tree);