You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vaInitialize() doesn't clean up properly on failure, so subsequent calls to vaInitialize() will lead to leaks of a /dev/dri/card or /dev/dri/renderD file descriptor. Eventually the fd limit is reached and no more files can be opened, leading to a crash with a message similar to:
XIO: fatal IO error 24 (Too many open files) on X server ":0"
after 6 requests (6 known processed) with 0 events remaining.
Attempting to call vaInitialize() again after a failure might seem contrived at first glance, but it is a reasonable thing to do for clients that might be using vaSetDriverName() to try to get one driver over another.
Either the documentation should clearly state that vaTerminate() must be called even after a failedvaInitialize() call (which invalidates the whole VADisplay), or a failed vaInitialize() should leave the VADisplay in a clean state to allow another initialization attempt.
Reproducer:
gcc valeak.c -o valeak -lva -lva-x11 -lX11
#include <va/va.h>
#include <va/va_x11.h>
#include <X11/Xlib.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
Display *x11_disp = XOpenDisplay(NULL);
if (!x11_disp) {
fprintf(stderr, "Unable to open X11 display\n");
return -1;
}
VADisplay va_disp = vaGetDisplay(x11_disp);
if (!va_disp) {
fprintf(stderr, "Unable to open VA display\n");
return -1;
}
for (;;) {
int major, minor;
vaSetDriverName(va_disp, "NotARealDriver");
VAStatus status = vaInitialize(va_disp, &major, &minor);
if (status == VA_STATUS_SUCCESS) {
fprintf(stderr, "vaInitialize() succeded with bogus driver name?\n");
abort();
}
else {
fprintf(stderr, "vaInitialize() failed: %s\n", vaErrorStr(status));
}
}
vaTerminate(va_disp);
XCloseDisplay(x11_disp);
}
Running lsof on the reproducer will show hundreds of leaked /dev/dri fds:
vaInitialize()
doesn't clean up properly on failure, so subsequent calls tovaInitialize()
will lead to leaks of a/dev/dri/card
or/dev/dri/renderD
file descriptor. Eventually the fd limit is reached and no more files can be opened, leading to a crash with a message similar to:Attempting to call
vaInitialize()
again after a failure might seem contrived at first glance, but it is a reasonable thing to do for clients that might be usingvaSetDriverName()
to try to get one driver over another.Either the documentation should clearly state that
vaTerminate()
must be called even after a failedvaInitialize()
call (which invalidates the wholeVADisplay
), or a failedvaInitialize()
should leave theVADisplay
in a clean state to allow another initialization attempt.Reproducer:
Running
lsof
on the reproducer will show hundreds of leaked/dev/dri
fds:The text was updated successfully, but these errors were encountered: