Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 656086 - media-video/mpv: USE="zsh-completion" fails when ffmpeg is built with USE="opencl" on mesa and using FEATURES="sandbox"
Summary: media-video/mpv: USE="zsh-completion" fails when ffmpeg is built with USE="op...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Coacher
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-19 02:01 UTC by Niklas Haas
Modified: 2018-05-27 08:51 UTC (History)
3 users (show)

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


Attachments
mpv build.log (build.log,478.72 KB, text/x-log)
2018-05-19 02:01 UTC, Niklas Haas
Details
emerge --info mpv (file_656086.txt,8.12 KB, text/plain)
2018-05-19 02:01 UTC, Niklas Haas
Details
emerge --info ffmpeg (file_656086.txt,8.66 KB, text/plain)
2018-05-19 02:01 UTC, Niklas Haas
Details
emerge --info mesa (file_656086.txt,8.05 KB, text/plain)
2018-05-19 02:02 UTC, Niklas Haas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niklas Haas 2018-05-19 02:01:18 UTC
Created attachment 532108 [details]
mpv build.log

The build script for USE="zsh-completion" requires running the compiled `mpv` binary, which fails the build when using the various portage sandbox features due to sandbox access violations:

    [439/439] Compiling TOOLS/zsh.pl
    02:17:52 runner ' "/usr/bin/perl" "/var/tmp/portage/media-video/mpv-9999/work/mpv-9999/TOOLS/zsh.pl" "/var/tmp/portage/media-video/mpv-9999/work/mpv-9999/build/mpv" > "etc/_mpv" '
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
     * ACCESS DENIED:  open_wr:      /dev/dri/renderD128
    Waf: Leaving directory `/var/tmp/portage/media-video/mpv-9999/work/mpv-9999/build'

This happens when ffmpeg is built with USE="opencl". Ultimately, this means that `libavcodec.so` links against `libOpenCL.so`:

    $ ldd /usr/lib/libavcodec.so | grep OpenCL
    	libOpenCL.so.1 => /usr/lib64/OpenCL/vendors/mesa/libOpenCL.so.1 (0x00007feea006e000)

On systems running mesa, this `libOpenCL.so` resolves to mesa's implementation, which always tries accessing `/dev/dri` and various other GPU-related device files on `dlopen()`:

    $ echo 'int main() {}' > test.c && gcc -o test test.c -lOpenCL && strace -e open ./test
    open("/dev/dri", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4
    open("/dev/dri", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4
    open("/dev/dri", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4
    open("/dev/dri", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4
    open("/sys/dev/char/226:128/device/drm", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4
    open("/sys/dev/char/226:128/device/drm", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 5
    open("/dev/dri", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 5
    open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 5
    open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 5
    open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 5
    open("/sys/dev/char/226:128/device/drm", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 5
    open("/sys/dev/char/226:128/device/drm", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 5
    open("/sys/dev/char/226:128/device/drm", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 5
    +++ exited with 0 +++

While this behavior for libOpenCL.so surprises me, and I'd personally feel this is an upstream bug, it still technically only affects the gentoo mpv build so I'm filing it here first.
Comment 1 Niklas Haas 2018-05-19 02:01:39 UTC
Created attachment 532110 [details]
emerge --info mpv
Comment 2 Niklas Haas 2018-05-19 02:01:56 UTC
Created attachment 532112 [details]
emerge --info ffmpeg
Comment 3 Niklas Haas 2018-05-19 02:02:07 UTC
Created attachment 532114 [details]
emerge --info mesa
Comment 4 Niklas Haas 2018-05-19 02:05:52 UTC
I've also pointed out the (IMHO) strange behavior upstream: https://bugs.freedesktop.org/show_bug.cgi?id=106572

We'll see what they have to say. It's also worth mentioning that IRC (via #dri-devel) suggests that `--enable-opencl-icd` might be a solution. I tried changing the mesa ebuild to set this flag (which is currently hard-coded to `--disable-opencl-icd`), but that causes `libOpenCL.so` to not get built, which means `eselect opencl mesa` fails with an error starting like this:

     !!! Error: The mesa OpenCL implementation doesn't seem to provide libOpenCL.so file.
Comment 5 Coacher 2018-05-20 14:14:33 UTC
Related discussion in g-dev ML:
https://archives.gentoo.org/gentoo-dev/message/c51b0a248cbebc2a242b4c72ec92efaa
Comment 6 Coacher 2018-05-20 14:23:49 UTC
Similar violations will probably occur when merging mpv-bash-completion as well.
Niklas, could you please test this?
Comment 7 Niklas Haas 2018-05-20 15:27:04 UTC
> Similar violations will probably occur when merging mpv-bash-completion as well.

Confirmed.
Comment 8 Stefan Strogin gentoo-dev 2018-05-27 03:31:23 UTC
> https://github.com/gentoo/gentoo/pull/8493

Fixed the issue for me (amd64, media-video/mpv-0.27.2). Thanks.
Comment 9 Larry the Git Cow gentoo-dev 2018-05-27 08:51:13 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ea7ba7c42a3f1564e612298e781e6fe8963b1e81

commit ea7ba7c42a3f1564e612298e781e6fe8963b1e81
Author:     Ilya Tumaykin <itumaykin@gmail.com>
AuthorDate: 2018-05-20 14:56:42 +0000
Commit:     Mikle Kolyada <zlogene@gentoo.org>
CommitDate: 2018-05-27 08:50:57 +0000

    media-video/mpv: addpredict /dev/dri with USE=zsh-completion
    
    Closes: https://bugs.gentoo.org/656086
    Package-Manager: Portage-2.3.38, Repoman-2.3.9

 media-video/mpv/mpv-0.27.2.ebuild | 4 ++++
 media-video/mpv/mpv-0.28.2.ebuild | 4 ++++
 media-video/mpv/mpv-9999.ebuild   | 4 ++++
 3 files changed, 12 insertions(+)

Additionally, it has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2078adf9f0884b0e954163e09924775bf4ec0170

commit 2078adf9f0884b0e954163e09924775bf4ec0170
Author:     Ilya Tumaykin <itumaykin@gmail.com>
AuthorDate: 2018-05-20 15:00:36 +0000
Commit:     Mikle Kolyada <zlogene@gentoo.org>
CommitDate: 2018-05-27 08:50:57 +0000

    app-shells/mpv-bash-completion: addpredict /dev/dri
    
    Bug: https://bugs.gentoo.org/656086
    Package-Manager: Portage-2.3.38, Repoman-2.3.9

 app-shells/mpv-bash-completion/mpv-bash-completion-3.3.16.ebuild | 4 ++++
 1 file changed, 4 insertions(+)