Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 654754 - media-libs/alsa-lib-1.1.6-r1 with ABI_X86=x32 - segmentation fault in libasound-2.0.0 when calling snd_pcm{,_plugin}_writei()
Summary: media-libs/alsa-lib-1.1.6-r1 with ABI_X86=x32 - segmentation fault in libasou...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo ALSA team
Depends on:
Blocks: x32
  Show dependency tree
Reported: 2018-05-03 17:18 UTC by Paul Bordukov
Modified: 2023-02-23 13:03 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---

session log from gdb (gdb_session.txt,3.40 KB, text/plain)
2018-05-03 17:18 UTC, Paul Bordukov
emerge info (emerge_info.txt,16.24 KB, text/plain)
2018-05-03 17:19 UTC, Paul Bordukov
gdb session (gdb_session.txt,2.09 KB, text/plain)
2018-05-03 17:44 UTC, Paul Bordukov
gdb session (gdb.txt,4.61 KB, text/plain)
2018-05-05 11:19 UTC, Paul Bordukov
mpv log (mpv.log,16.99 KB, text/plain)
2018-05-05 11:19 UTC, Paul Bordukov

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Bordukov 2018-05-03 17:18:57 UTC
Created attachment 529632 [details]
session log from gdb

Hello, my mpv got segfault in libasound trying to play video ( saved locally (other videos give same error):

pashgan@light ~/temp $ mpv ./SampleVideo_1280x720_10mb.mp4 
Playing: ./SampleVideo_1280x720_10mb.mp4
 (+) Video --vid=1 (*) (h264 1280x720 25.000fps)
 (+) Audio --aid=1 --alang=und (*) (aac 6ch 48000Hz)
AO: [alsa] 48000Hz stereo 2ch float
VO: [opengl] 1280x720 yuv420p
Segmentation fault

dmesg shows:
[ 3129.052543] traps: mpv/ao[6305] general protection ip:f295115a sp:e47f2d00 error:0 in[f28d6000+e9000]

emerge info and gdb session attached.

I've tried to compile alsa-lib and mpv with different CFLAGS and gcc (7.3, 6.4) but without any luck.

What I need/can to try else? How to debug libasoud properly (splitdebug and -gddb flags are in place according to wiki)?
Comment 1 Paul Bordukov 2018-05-03 17:19:42 UTC
Created attachment 529634 [details]
emerge info
Comment 2 Paul Bordukov 2018-05-03 17:44:16 UTC
Created attachment 529636 [details]
gdb session
Comment 3 Paul Bordukov 2018-05-04 04:25:04 UTC

mpv = 0.27.2 (X alsa cli drm egl iconv jpeg libass lua opengl tools uchardet vaapi vdpau wayland xv zlib -aqua -archive -bluray -cdda -coreaudio -cplugins -cuda -doc -dvb -dvd -encode -gbm -jack -javascript -lcms -libav -libcaca -libmpv -luajit -openal -oss -pulseaudio -raspberry-pi -rubberband -samba -sdl -selinux -test -v4l -zsh-completion PYTHON_TARGETS="python2_7 python3_5 -python3_4 -python3_6")

alsa-lib = 1.1.6-r1 (debug thread-safety -alisp -doc -python ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="64 x32 -32" ELIBC="-uclibc" PYTHON_SINGLE_TARGET="python3_5 -python2_7 -python3_4 -python3_6" PYTHON_TARGETS="python2_7 python3_5 -python3_4 -python3_6")
Comment 4 Paul Bordukov 2018-05-04 08:22:32 UTC
Bug was reported in alsa-devel mail list as well:
Comment 5 Coacher 2018-05-04 11:26:07 UTC
1. Please rebuild mpv, alsa-lib and other relevant pieces with CFLAGS="-O2".
   "-O3" in CFLAGS is generally not supported. Then check if the issue is
   still reproducible.

2. Your gdb backtrace is incomplete (notice ??).
   Please enable debugging info in alsa-lib, mpv, glibc and other relevant pieces,
   then attach a complete backtrace.

3. Please run mpv like this:
   `mpv --no-config --log-file=mpv.log'
    Then attach the resulting mpv.log file here.
Comment 6 Paul Bordukov 2018-05-05 11:18:23 UTC
True, I used O3. Now I recompiled mpv, glibc, ffmpeg, mesa, alsa-lib with -O2 and debubgsyms. New backtrace and are mpv.log attached.
Comment 7 Paul Bordukov 2018-05-05 11:19:32 UTC
Created attachment 529948 [details]
gdb session
Comment 8 Paul Bordukov 2018-05-05 11:19:53 UTC
Created attachment 529950 [details]
mpv log
Comment 9 Coacher 2018-05-05 13:54:30 UTC
Thank you very much. I will try to reproduce your problem here.
Comment 10 Paul Bordukov 2018-05-05 17:04:26 UTC
Thank you! I appreciate this.
Comment 11 Coacher 2018-05-06 17:37:39 UTC
Ok, cannot reproduce on my regular system.
Will create ABI=x32 chroot next and try there.
It will take some time.

I have one more request beforehand, though.
Just to make sure it's a problem with mpv,
could you please do the following:
0. Build media-video/ffmpeg with USE=sdl enabled
1. Run `ffplay -hide_banner' and see if it plays your file.
Comment 12 Paul Bordukov 2018-05-08 13:17:15 UTC
It works, no issues with sound or segmentation faults.

pashgan@light ~ $ ffplay -hide_banner ./temp/SampleVideo_1280x720_10mb.mp4 
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './temp/SampleVideo_1280x720_10mb.mp4':
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01T00:00:00.000000Z
    encoder         : Lavf53.24.2
  Duration: 00:01:02.32, start: 0.000000, bitrate: 1347 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 959 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
      creation_time   : 1970-01-01T00:00:00.000000Z
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
      creation_time   : 1970-01-01T00:00:00.000000Z
      handler_name    : SoundHandler
   2.60 A-V:  0.031 fd=   0 aq=   54KB vq=  133KB sq=    0B f=0/0
Comment 13 Paul Bordukov 2018-05-08 17:31:36 UTC
Interesting thing, I've added alsa-plugins with USE="pulseaudio" in my system, and mpv started to work normally, using same plain alsa output. Mpv itself has no pulseaudio support, i.e. USE="-pulseaudio".
Comment 14 Coacher 2018-05-08 19:21:37 UTC
(In reply to Paul Bordukov from comment #13)
> Interesting thing, I've added alsa-plugins with USE="pulseaudio" in my
> system, and mpv started to work normally, using same plain alsa output. Mpv
> itself has no pulseaudio support, i.e. USE="-pulseaudio".
Interesting. Please help me understand.

1. From your `emerge --info` and `emerge -pqv mpv` I concluded that your system doesn't have pulseaudio installed. Correct?

2. You didn't previously have alsa-plugins installed at all when you had crashes. Correct?
Comment 15 Paul Bordukov 2018-05-09 08:10:28 UTC
1. right, I've added it recently, because firefox-bin requires pulseaudio for sound, and I cannot build firefox w/o pulseaudio because firefox ebild broken: But all tests you asked me to do I did w/o pulseaudio

2. correct, I want to use plain alsa, w/o any plugins, so no alsa-plugins were installed
Comment 16 Coacher 2018-07-05 10:43:32 UTC
Ok, I am able to reproduce this in a current Gentoo ~amd64-x32 chroot.
Not sure yet if it's mpv's problem or alsa's.
Comment 17 Coacher 2018-07-05 10:47:07 UTC
Same with different audio only files (flac, vorbis, ac3, mp3).
Comment 18 Coacher 2018-07-05 11:48:56 UTC
Not reproducible on amd64, ~amd64, x86 systems.
Exclusive to amd64+x32.
Comment 19 Coacher 2018-07-08 15:07:09 UTC
If I install alsa-plugins without pulseaudio, the problem is still reproducible.
Comment 20 Coacher 2018-07-08 15:13:02 UTC
The cause of this crash is somewhere in mix_areas_32_smp() function,
which eventually gets called from snd_pcm_plugin_writei() function.

This crash is easily reproducible with a very minimal test program shipped with alsa-lib:;a=blob;f=test/pcm_min.c;h=7462a45fef332d1027b3a3dfe0df550e0faa5c9d;hb=HEAD
(Just do `gcc -lasound pcm_min.c; ./a.out`)

This program just calls snd_pcm_plugin_writei() right away and crashes.
Thus this isn't a problem with mpv, but rather with alsa-lib itself.
Reassigning to alsa-lib maintainers.
Comment 21 Pacho Ramos gentoo-dev 2022-12-25 10:13:09 UTC
Still valid with an updated system? In that case I would report it to upstream, or I don't think it will be fixed ever