[Ubuntu] Segfault when using xv, x11, opengl if SDL2 is enabled
Under 13.04, I'm getting segfaults before playback starts when trying to use any of the above three vos (SDL2 and caca are unaffected). This didn't occur under 12.10.
Backtraces:
$ gdb mpv GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /home/qyot27/mpvdebug/bin/mpv...done. (gdb) r -vo x11 ~/Videos/flicktest.avs Starting program: /home/qyot27/mpvdebug/bin/mpv -vo x11 ~/Videos/flicktest.avs [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". Playing /home/qyot27/Videos/flicktest.avs. Detected file format: AviSynth script (libavformat) [stream] Video (+) --vid=0 (rawvideo) [stream] Audio (+) --aid=0 (pcm_s16le)
Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt
0 0x00000000 in ?? ()
1 0x081921e8 in vo_x11_init (vo=vo@entry=0x96168e8)
at video/out/x11_common.c:4372 0x081999be in preinit (vo=0x96168e8, arg=0x0) at video/out/vo_x11.c:640
3 0x08150514 in vo_preinit (vo=vo@entry=0x96168e8, arg=arg@entry=0x0)
at video/out/vo.c:1334 0x08150dcc in init_best_video_out (opts=opts@entry=0x957bec0,
key_fifo=0x95a50d8, input_ctx=0x95b5948, encode_lavc_ctx=0x0) at video/out/vo.c:3355 0x080e460c in reinit_video_chain (mpctx=mpctx@entry=0x957be90)
at core/mplayer.c:23666 0x080b1ec4 in play_current_file (mpctx=
) at core/mplayer.c:41587 play_files (mpctx=
) at core/mplayer.c:4341 8 main (argc=157183376, argv=0x8c04efa) at core/mplayer.c:4565
(gdb)
$ gdb mpv GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /home/qyot27/mpvdebug/bin/mpv...done. (gdb) r -vo xv ~/Videos/flicktest.avs Starting program: /home/qyot27/mpvdebug/bin/mpv -vo xv ~/Videos/flicktest.avs [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". Playing /home/qyot27/Videos/flicktest.avs. Detected file format: AviSynth script (libavformat) [stream] Video (+) --vid=0 (rawvideo) [stream] Audio (+) --aid=0 (pcm_s16le)
Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt
0 0x00000000 in ?? ()
1 0x081921e8 in vo_x11_init (vo=vo@entry=0x9747940)
at video/out/x11_common.c:4372 0x0819afa8 in preinit (vo=0x9747940, arg=0x0) at video/out/vo_xv.c:801
3 0x08150514 in vo_preinit (vo=vo@entry=0x9747940, arg=arg@entry=0x0)
at video/out/vo.c:1334 0x08150dcc in init_best_video_out (opts=opts@entry=0x957bec0,
key_fifo=0x95be820, input_ctx=0x95b5948, encode_lavc_ctx=0x0) at video/out/vo.c:3355 0x080e460c in reinit_video_chain (mpctx=mpctx@entry=0x957be90)
at core/mplayer.c:23666 0x080b1ec4 in play_current_file (mpctx=
) at core/mplayer.c:41587 play_files (mpctx=
) at core/mplayer.c:4341 8 main (argc=157369008, argv=0x8c04efa) at core/mplayer.c:4565
(gdb)
$ gdb mpv GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /home/qyot27/mpvdebug/bin/mpv...done. (gdb) r -vo opengl ~/Videos/flicktest.avs Starting program: /home/qyot27/mpvdebug/bin/mpv -vo opengl ~/Videos/flicktest.avs [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". Playing /home/qyot27/Videos/flicktest.avs. Detected file format: AviSynth script (libavformat) [stream] Video (+) --vid=0 (rawvideo) [stream] Audio (+) --aid=0 (pcm_s16le)
Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt
0 0x00000000 in ?? ()
1 0x081921e8 in vo_x11_init (vo=0x974a908) at video/out/x11_common.c:437
2 0x0817e4e6 in init_backend (vo=vo@entry=0x974a908,
set_backend=0x8195460 <mpgl_set_backend_x11>) at video/out/gl_common.c:8863 0x0817f81a in mpgl_init (vo=vo@entry=0x974a908, backend_name=0x0)
at video/out/gl_common.c:8994 0x0818083e in preinit (vo=0x974a908, arg=0x0) at video/out/vo_opengl.c:299
5 0x08150514 in vo_preinit (vo=vo@entry=0x974a908, arg=arg@entry=0x0)
at video/out/vo.c:1336 0x08150dcc in init_best_video_out (opts=opts@entry=0x957bec0,
key_fifo=0x95a7920, input_ctx=0x95b5958, encode_lavc_ctx=0x0) at video/out/vo.c:3357 0x080e460c in reinit_video_chain (mpctx=mpctx@entry=0x957be90)
at core/mplayer.c:23668 0x080b1ec4 in play_current_file (mpctx=
) at core/mplayer.c:41589 play_files (mpctx=
) at core/mplayer.c:4341 10 main (argc=157734384, argv=0x8c04efa) at core/mplayer.c:4565
(gdb)
Maybe you could use git bisect to find the commit which causes the segmented faults, in case some recent changes make it incompatible with ubuntu 13.04.
I find this quite mysterious... all it does on line 437 is calling XSetErrorHandler(). And then it looks like it calls a function pointer that is set to NULL. mplayer-svn and mplayer2 still contain the same code.
Tried on Ubuntu 13.04, can't reproduce.
Might it have something to do with the graphics drivers then? While it didn't segfault, I did notice that my 12.10 VM throws up a bunch of gl error messages when I tried to do the same thing (the working 12.10 install I was referring to previously was my main environment, the VM is just for compiling things faster). The 12.10 install was using the proprietary nvidia drivers, but since I started having problems with it not remembering my gamma settings I decided on keeping 13.04 with nouveau and using xgamma instead. I can't seem to find any reference to nouveau having issues with XSetErrorHandler, so I can't be sure that's what it is. I'll have to test it and see if installing the proprietary driver fixes the problem.
If it is graphics driver related, that'd obviously put it outside the scope of this issue report.
Might it have something to do with the graphics drivers then? While it didn't segfault, I did notice that my 12.10 VM throws up a bunch of gl error messages when I tried to do the same thing (the working 12.10 install I was referring to previously was my main environment, the VM is just for compiling things faster). The 12.10 install was
The -vo opengl output tries to create a GL 3.0 context, and falls back to 2.1 if that fails. This prints some error messages/warnings. Should be harmless, and it sounds like -vo xv and -vo x11 were working fine anyway.
I really have no idea what's going wrong. Maybe the crash is a random consequence of a bug in unrelated code. A graphics driver issue sounds unlikely to me, unless the driver is somehow completely broken.
Did you test with mplayer1 and mplayer2?
No, I didn't test with mplayer1 or mplayer2, but it turns out I didn't have to (and switching to the proprietary driver didn't fix it either).
Turns out that SDL2 is what's causing it. If I disable it during configure, then xv, x11, and opengl start working properly again. That's why I never saw it happen on 12.10, since I never bothered to install SDL2 for Linux on 12.10, I only cross-compiled it and linked it into my Windows builds.
I wanted to try to reproduce this, but Ubuntu 13.04 doesn't seem to have a sdl2 packet. All I see is sdl 1.2. Where did you get it from?
I compiled it from source,
sudo apt-get install mercurial hg clone http://hg.libsdl.org/SDL mkdir build && cd build ../configure --disable-shared --enable-ssemath make sudo checkinstall --pkgname=sdl2 --pkgversion="$(grep Version sdl2.pc | sed 's/: /\t/g' | cut -f2)-hg" --backup=no --deldoc=yes --fstrans=no --default
I didn't mean to close this. Clicked wrong.
Tried with a Mercurial version from now and from some months ago, still no segfault. This time I tried this on Debian though, not Ubuntu.
Throwing some ideas out here,
Could it be related to 32-bit/64-bit differences? I've not had the opportunity to test under the machine I usually use for 64-bit tests, so the only platform I've tested on is my (PIII-based) Celeron Coppermine.
The segfault is actually in SDL2 itself, but this ends up cascading into the other vos that rely on X? This doesn't explain why using -vo sdl worked, though.
Having SDL2 and the X-related vos enabled together conflict only when using SDL2 as static? The dev libraries for the other vos are the repository versions.
OK, could reproduce it. It happens if you statically link SDL2. XSetErrorHandler() is not actually a function, but a variable, and it appears libsdl overwrites this. Apparently they use constructor functions which are run at program start, and that sets the X error handler.
Actually it's even easier, it's just a simple namespace clash. Reported it: http://bugzilla.libsdl.org/show_bug.cgi?id=1828
Not sure if they accept that as bug, the resolution might be that you can't statically link mpv with SDL2 and still expect X11 to work.
So that's what it's doing. It kind of, almost, not really sounds like the atexit problem the new AviSynth demuxer in libavformat had to compensate for (it wasn't namespaces though; but it did arise because of conflicts with dlopen usage).
OK, seeing the reaction on the SDL bug tracker, I'm pretty sure it's definitely a libSDL issue.
SDL marked the bug report as invalid.