Menu

#294 Segfault when file is changing (download completes)

v1.0 (example)
open
segfault (1)
5
2017-02-07
2016-11-01
huszty
No

Hi,
I've discovered a segfault in the latest release (1.1-5). I am running minidlna on alpine linux in a docker container.
Package: https://pkgs.alpinelinux.org/flag/edge/main/minidlna/1.1.5-r2
Container: https://github.com/vimagick/dockerfiles/tree/master/minidlna
Docker-compose file: http://pastebin.com/cuiCWzZZ
Minidlna config: http://pastebin.com/N0VqmVqQ

The problem comes when the scanning has succeded and later on I download a new file through rtorrent (running in another container).
Debug log from minidlna with comments: http://pastebin.com/xB4YHmxh

Here is the kernel log about the event:
Nov 1 14:13:08 lhs kernel: [1007319.342237] minidlnad[31295]: segfault at 7f3e4e717238 ip 000055a1b3b37e39 sp 00007f3e4e717240 error 6 in minidlnad[55a1b3b1f000+39000]

MD5 hash for the minidlnad binary: a03fea052f413d5add136e49175908fa

I could not reproduce the issue so far by manually creating and changing files.
If I can provide more symtoms, please tell.

Discussion

  • huszty

    huszty - 2016-11-01

    Finnaly reproduced the crash with debug symbols.
    Please find the backtrace here: http://pastebin.com/6jx9SNGb

     
  • Shrimpkin

    Shrimpkin - 2016-11-05

    Do you get this problem without using docker containers?

     
    • huszty

      huszty - 2016-11-14

      Not tried yet, because my host OS is debian (strech). Alpine comes with a different libc distribution, so I don't think I could even run alpine-compiled binary on debian. Or shall I recompile the same source for debian and run it like that?

       
  • huszty

    huszty - 2016-11-14

    I found an interesting workaround for the problem. If I set the plugin "auto-move" on in rtorrent and download the stuff under a temporary place, than with auto-move I get the content to the place where minidlna listens, the problem looks like to disappear. I have no exaplanation for that so far. May help for others as well...

     
  • Shrimpkin

    Shrimpkin - 2016-11-23

    Maybe try debian minidlna + rtorrent without containers to see if problem still exists.

    It is probably best to keep files being modified outside of media_dir (or put in hidden dir) because minidlna will remove and re-add the file to the database each time the file is modified.

     
  • huszty

    huszty - 2017-02-04

    Hello,
    Finnaly had time to debug this. Basically it caused stack underrun, and so SIGSEGV on my system (with 8192k stack ulimit size)

    I've corrected multiple issues in this metadata.c patch:
    http://pastebin.com/sY8401dv
    - uninitalized string (GetVideoMetadata() - nfo) -> memset to 0
    - stack was kicked with 64k buffer unconditionally (parse_nfo() - buf) -> now it is on heap and malloc'd size depends on filesize

    Please add to the mainline if it seems ok.

     
  • huszty

    huszty - 2017-02-07

    Please note that alpine linux accepted an improved version of the patch:
    http://patchwork.alpinelinux.org/patch/2940/

     

Log in to post a comment.