Instead of just segfaulting in the driver when a buffer allocation fails,
report error messages indicating what went wrong so that we can debug things.
As a simple example, chromium wraps Mesa in a sandbox which doesn't allow
access to most syscalls, including the ability to create shared memory
segments for fences. Before, you'd get a simple segfault in mesa and your 3D
acceleration would fail. Now you get:
$ chromium --disable-gpu-blacklist
[10618:10643:0930/200525:ERROR:nss_util.cc(856)] After loading Root Certs, loaded==false: NSS error code: -8018
libGL: pci id for fd 12: 8086:0a16, driver i965
libGL: OpenDriver: trying /local-miki/src/mesa/mesa/lib/i965_dri.so
libGL: Can't open configuration file /home/keithp/.drirc: Operation not permitted.
libGL: Can't open configuration file /home/keithp/.drirc: Operation not permitted.
libGL error: DRI3 Fence object allocation failure Operation not permitted
[10618:10618:0930/200525:ERROR:command_buffer_proxy_impl.cc(153)] Could not send GpuCommandBufferMsg_Initialize.
[10618:10618:0930/200525:ERROR:webgraphicscontext3d_command_buffer_impl.cc(236)] CommandBufferProxy::Initialize failed.
[10618:10618:0930/200525:ERROR:webgraphicscontext3d_command_buffer_impl.cc(256)] Failed to initialize command buffer.
This made it pretty easy to diagnose the problem in the referenced bug report.
Bugzilla: https://code.google.com/p/chromium/issues/detail?id=415681
Signed-off-by: Keith Packard <keithp@keithp.com>
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Matt Turner <mattst88@gmail.com>
*/
fence_fd = xshmfence_alloc_shm();
*/
fence_fd = xshmfence_alloc_shm();
+ if (fence_fd < 0) {
+ ErrorMessageF("DRI3 Fence object allocation failure %s\n", strerror(errno));
shm_fence = xshmfence_map_shm(fence_fd);
shm_fence = xshmfence_map_shm(fence_fd);
+ if (shm_fence == NULL) {
+ ErrorMessageF("DRI3 Fence object map failure %s\n", strerror(errno));
/* Allocate the image from the driver
*/
/* Allocate the image from the driver
*/
goto no_buffer;
buffer->cpp = dri3_cpp_for_format(format);
goto no_buffer;
buffer->cpp = dri3_cpp_for_format(format);
+ if (!buffer->cpp) {
+ ErrorMessageF("DRI3 buffer format %d invalid\n", format);
if (!psc->is_different_gpu) {
buffer->image = (*psc->image->createImage) (psc->driScreen,
if (!psc->is_different_gpu) {
buffer->image = (*psc->image->createImage) (psc->driScreen,
buffer);
pixmap_buffer = buffer->image;
buffer);
pixmap_buffer = buffer->image;
+ if (!buffer->image) {
+ ErrorMessageF("DRI3 gpu image creation failure\n");
} else {
buffer->image = (*psc->image->createImage) (psc->driScreen,
width, height,
} else {
buffer->image = (*psc->image->createImage) (psc->driScreen,
width, height,
+ if (!buffer->image) {
+ ErrorMessageF("DRI3 other gpu image creation failure\n");
buffer->linear_buffer = (*psc->image->createImage) (psc->driScreen,
width, height,
buffer->linear_buffer = (*psc->image->createImage) (psc->driScreen,
width, height,
buffer);
pixmap_buffer = buffer->linear_buffer;
buffer);
pixmap_buffer = buffer->linear_buffer;
- if (!buffer->linear_buffer)
+ if (!buffer->linear_buffer) {
+ ErrorMessageF("DRI3 gpu linear image creation failure\n");
}
/* X wants the stride, so ask the image for it
*/
}
/* X wants the stride, so ask the image for it
*/
- if (!(*psc->image->queryImage)(pixmap_buffer, __DRI_IMAGE_ATTRIB_STRIDE, &stride))
+ if (!(*psc->image->queryImage)(pixmap_buffer, __DRI_IMAGE_ATTRIB_STRIDE, &stride)) {
+ ErrorMessageF("DRI3 get image stride failed\n");
- if (!(*psc->image->queryImage)(pixmap_buffer, __DRI_IMAGE_ATTRIB_FD, &buffer_fd))
+ if (!(*psc->image->queryImage)(pixmap_buffer, __DRI_IMAGE_ATTRIB_FD, &buffer_fd)) {
+ ErrorMessageF("DRI3 get image FD failed\n");
xcb_dri3_pixmap_from_buffer(c,
(pixmap = xcb_generate_id(c)),
xcb_dri3_pixmap_from_buffer(c,
(pixmap = xcb_generate_id(c)),
xshmfence_unmap_shm(shm_fence);
no_shm_fence:
close(fence_fd);
xshmfence_unmap_shm(shm_fence);
no_shm_fence:
close(fence_fd);
+ ErrorMessageF("DRI3 alloc_render_buffer failed\n");