mpv segfaults when trying to load some subtitled mkv files
I updated to the latest HEAD from the master branch and started seeing segfaults on some video files:
$ mpv file.mkv
Playing file.mkv.
Detected file format: Matroska
Segmentation fault (core dumped)
With some trial and error I could isolate the faulty commit as dc475728e0fd395e0780a2e41b0dc19af162e383. Anything before that works. Bellow is a backtrace using gdb:
#0 0x00007ffff086f5a1 in __memmove_ssse3 () from /usr/lib/libc.so.6
No symbol table info available.
#1 0x0000000000463671 in memmove (__len=18446744073709551600,
__src=0x12c3480, __dest=0x12c3470) at /usr/include/bits/string3.h:57
No locals.
#2 filter_subidx (nsub=0x7fffffffe794, slist=0x7fffffffe798)
at sub/find_subfiles.c:217
at_ = 0
n = <optimized out>
prev = <optimized out>
#3 find_text_subtitles (opts=opts@entry=0x796010, fname=<optimized out>)
at sub/find_subfiles.c:248
subnames = 0x0
slist = 0x12c3470
n = 0
mp_subdir = <optimized out>
#4 0x0000000000414960 in open_subtitles_from_options (mpctx=0x7956e0)
at mpvcore/mplayer.c:4004
tmp = <optimized out>
nsub = <optimized out>
#5 play_current_file (mpctx=0x7956e0) at mpvcore/mplayer.c:4402
opts = <optimized out>
startpos = <optimized out>
uninitialize_parts = <optimized out>
stream_filename = <optimized out>
res = <optimized out>
#6 play_files (mpctx=0x7956e0) at mpvcore/mplayer.c:4597
new_entry = <optimized out>
#7 mpv_main (argv=<optimized out>, argc=<optimized out>)
at mpvcore/mplayer.c:4840
mpctx = 0x7956e0
opts = <optimized out>
r = <optimized out>
#8 main (argc=<optimized out>, argv=<optimized out>) at mpvcore/mplayer.c:4852
No locals.
If any information is missing, please tell me and I can provide it, I don't have much experience making bug reports. I don't think I can link a file that presents this issue here because of copyright issues.
I had not tried to debug this since I have absolutely no knowledge of the codebase, but turns out a fix was easy enough, applying this patch fixes the problem for me:
http://pastebin.com/v7i4rHzc
Yep, a stupid off by 1 error. I changed the commit message a bit. Thanks!