ports/185155: minidlna with kqueue crashes on large media collections

Stefan Esser se at freebsd.org
Tue Dec 24 13:30:02 UTC 2013


>Number:         185155
>Category:       ports
>Synopsis:       minidlna with kqueue crashes on large media collections
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 24 13:30:01 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Esser
>Release:        FreeBSD 11.0-CURRENT amd64
>Organization:
>Environment:
System: FreeBSD test.local 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r259736M: Sun Dec 22 21:53:27 CET 2013 se at test.local:/usr/obj/usr/src/sys/SE amd64
>Description:
The kqueue support that was added to minidlna uses one file descriptor per
watched directory, starting with low file descriptor IDs. On a system with
many media directories (those taking most profit from the kqueue patch),
this leads to a program crash, when the file descriptors used for the actual
data transfer have numbers higher than FD_SETSIZE (1024 unless changed).
The diagnostig written to the log file does not explain the reason for the
crash and does not provide any guidance to resolve the problem.

>How-To-Repeat:
Start minidlna on a media collection consisting of more than 1024 directories
and with "inotify=yes" (the default) in minidlna.conf. The program will crash
when the first actual data transfer is attempted.
>Fix:
As a work-round, FD_SETSIZE may be defined to a larger value before the
#include of sys/types.h (and any otherheader that implicitly loads this file).

For a real fix, select() should be replaced by poll(). With large numbers of
file descriptors, select is inefficient, anyway. Since the FD_*() macros and
the select() system call are used in only a few places, the change is not too
intrusive.

As a work-around the following two patches rise the limit of file-descriptors
supported by select() (and thus the number of directories) to a much higher
value and provide a better error message, if the number of file descriptors
supported is still too low.

--- minidlna.c.orig	2013-11-02 02:06:41.000000000 +0100
+++ minidlna.c	2013-12-24 12:26:09.673738901 +0100
@@ -46,6 +46,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#define FD_SETSIZE 8192
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>

--- upnpevents.c~	2013-11-02 02:06:41.000000000 +0100
+++ upnpevents.c	2013-12-24 12:22:41.533935174 +0100
@@ -416,6 +416,10 @@
 {
 	struct upnp_event_notify * obj;
 	for(obj = notifylist.lh_first; obj != NULL; obj = obj->entries.le_next) {
+		if (obj->s > FD_SETSIZE)
+			DPRINTF(E_FATAL, L_HTTP,
+			    "upnpevents_selectfds: file descriptor %d too big for select, limit is %d\n", 
+			    obj->s, FD_SETSIZE);
 		DPRINTF(E_DEBUG, L_HTTP, "upnpevents_selectfds: %p %d %d\n",
 		       obj, obj->state, obj->s);
 		if(obj->s >= 0) {
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-ports-bugs mailing list