Bug 71002 - Segfault when calling glCompressedTexImage2D with ETC2 textures
Summary: Segfault when calling glCompressedTexImage2D with ETC2 textures
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i915 (show other bugs)
Version: 9.2
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Ian Romanick
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-29 14:33 UTC by Elias Naur
Modified: 2014-02-12 20:26 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
test program (6.27 KB, text/plain)
2013-10-29 14:33 UTC, Elias Naur
Details

Description Elias Naur 2013-10-29 14:33:10 UTC
Created attachment 88304 [details]
test program

The attached test program, adapted from the similarly named mesa demo is crashing on my Lenovo X1 Carbon with an Intel graphics card ("3rd Gen Core processor Graphics Controller" according to lshw) running Ubuntu 13.10.

The full session of compiling and running the program is below. The program crashes on uploading the 1x1 mipmap of a texture.

I'm aware that the texture data contains whatever garbage malloc returns, but the full program where I stumbled on this bug exhibit the same crash with valid ETC2 data, so I don't think the actual image data is relevant.



elias@elias-x1:~/Downloads$ gcc es2tri.c -lGL -lEGL -lX11 -lm && ./a.out ^C
elias@elias-x1:~/Downloads$ gdb a.out 
GNU gdb (GDB) 7.6.1-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 "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/elias/Downloads/a.out...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/elias/Downloads/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
libEGL warning: failed to create a pipe screen for i965
EGL_VERSION = 1.4 (DRI2)
EGL_VENDOR = Mesa Project
EGL_EXTENSIONS = EGL_MESA_drm_image EGL_WL_bind_wayland_display EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_surfaceless_context EGL_KHR_create_context EGL_NOK_swap_region EGL_NOK_texture_from_pixmap EGL_NV_post_sub_buffer 
EGL_CLIENT_APIS = OpenGL OpenGL_ES OpenGL_ES2 OpenGL_ES3 
w 1024 h 1024 d size 1048576 level 0
w 512 h 512 d size 262144 level 1
w 256 h 256 d size 65536 level 2
w 128 h 128 d size 16384 level 3
w 64 h 64 d size 4096 level 4
w 32 h 32 d size 1024 level 5
w 16 h 16 d size 256 level 6
w 8 h 8 d size 64 level 7
w 4 h 4 d size 16 level 8
w 2 h 2 d size 16 level 9
w 1 h 1 d size 16 level 10

Program received signal SIGSEGV, Segmentation fault.
etc2_rgb8_fetch_texel (block=block@entry=0x7fffffffd900, x=104, x@entry=0, y=104, y@entry=2, dst=0x7fffeef36800 <Address 0x7fffeef36800 out of bounds>, 
    punchthrough_alpha=punchthrough_alpha@entry=0 '\000') at ../../../../../src/mesa/main/texcompress_etc.c:504
504	../../../../../src/mesa/main/texcompress_etc.c: No such file or directory.
=> 0x00007ffff33c58ed <etc2_rgb8_fetch_texel+141>:	41 88 11	mov    %dl,(%r9)
(gdb) bt
#0  etc2_rgb8_fetch_texel (block=block@entry=0x7fffffffd900, x=104, x@entry=0, y=104, y@entry=2, dst=0x7fffeef36800 <Address 0x7fffeef36800 out of bounds>, 
    punchthrough_alpha=punchthrough_alpha@entry=0 '\000') at ../../../../../src/mesa/main/texcompress_etc.c:504
#1  0x00007ffff33c5c7a in etc2_rgba8_fetch_texel (block=block@entry=0x7fffffffd900, x=x@entry=0, y=y@entry=2, 
    dst=dst@entry=0x7fffeef36800 <Address 0x7fffeef36800 out of bounds>) at ../../../../../src/mesa/main/texcompress_etc.c:663
#2  0x00007ffff33c7119 in etc2_unpack_rgba8 (height=<optimised out>, width=<optimised out>, src_stride=<optimised out>, src_row=0x6f3770 "`:l", dst_stride=<optimised out>, 
    dst_row=<optimised out>) at ../../../../../src/mesa/main/texcompress_etc.c:770
#3  _mesa_unpack_etc2_format (dst_row=0x7fffeef34800 <Address 0x7fffeef34800 out of bounds>, dst_stride=4096, src_row=<optimised out>, src_stride=16, src_width=1, 
    src_height=1, format=format@entry=MESA_FORMAT_ETC2_RGBA8_EAC) at ../../../../../src/mesa/main/texcompress_etc.c:1189
#4  0x00007ffff0c4157a in intel_miptree_unmap_etc (slice=0, level=<optimised out>, map=0x7a20e0, mt=0x7a1690, brw=0x627e00)
    at ../../../../../../../src/mesa/drivers/dri/i965/intel_mipmap_tree.c:1900
#5  intel_miptree_unmap_singlesample (brw=0x627e00, mt=0x7a1690, level=<optimised out>, slice=0) at ../../../../../../../src/mesa/drivers/dri/i965/intel_mipmap_tree.c:2175
#6  0x00007ffff33e3478 in _mesa_store_compressed_texsubimage (ctx=ctx@entry=0x627e00, dims=dims@entry=2, texImage=texImage@entry=0x7a2260, xoffset=xoffset@entry=0, 
    yoffset=yoffset@entry=0, zoffset=zoffset@entry=0, width=1, height=1, depth=1, format=147, imageSize=imageSize@entry=16, data=<optimised out>, data@entry=0x6c3170)
    at ../../../../../src/mesa/main/texstore.c:4183
#7  0x00007ffff33e354c in _mesa_store_compressed_teximage (ctx=0x627e00, dims=2, texImage=0x7a2260, imageSize=16, data=0x6c3170)
    at ../../../../../src/mesa/main/texstore.c:4121
#8  0x00007ffff33d1607 in teximage (ctx=0x627e00, compressed=compressed@entry=1 '\001', dims=dims@entry=2, target=3553, level=<optimised out>, internalFormat=8004192, 
    width=1, height=1, depth=depth@entry=1, border=0, format=format@entry=0, type=type@entry=0, imageSize=imageSize@entry=16, pixels=pixels@entry=0x6c3170)
    at ../../../../../src/mesa/main/teximage.c:3162
#9  0x00007ffff33d3161 in _mesa_CompressedTexImage2D (target=<optimised out>, level=<optimised out>, internalFormat=<optimised out>, width=<optimised out>, 
    height=<optimised out>, border=<optimised out>, imageSize=16, data=0x6c3170) at ../../../../../src/mesa/main/teximage.c:3827
#10 0x00000000004012ca in create_texture ()
#11 0x0000000000401a88 in main ()
Comment 1 Ian Romanick 2014-02-12 20:26:34 UTC
It looks like this was fixed on Mesa master by the following commit.  I've nominated this commit for the 10.0 branch, so it should get picked up in 10.0.4.

commit 6b40dd17cf844b9cc8d6b1a816d4e93cbf6decef
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Nov 12 17:16:25 2013 -0800

    i965/gen7: Prefer vertical alignment of 4 when possible.
    
    Gen6+ allows for color buffers to use a vertical alignment of either 4
    or 2.  Previously we defaulted to 2.  This may have caused problems on
    Gen7 because Y-tiled render targets are not allowed to use a vertical
    alignment of 2.
    
    This patch changes the vertical alignment to 4 on Gen7, except for the
    few formats where a vertical alignment of 2 is required.
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.